
Keyless

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera
local KEY = Enum.KeyCode.C
local DISTANCE = 4
local enabled = false
local targetHRP = nil
local loop = nil
local function hrp(plr)
return plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
end
local function closestToMouse()
local mouse = UserInputService:GetMouseLocation()
local best, bestDist = nil, math.huge
for _, p in ipairs(Players:GetPlayers()) do
if p ~= LocalPlayer then
local h = hrp(p)
if h then
local v, on = Camera:WorldToViewportPoint(h.Position)
if on then
local d = (Vector2.new(v.X, v.Y) - mouse).Magnitude
if d < bestDist then
bestDist = d
best = h
end
end
end
end
end
return best
end
local function start()
local myHRP = hrp(LocalPlayer)
if not myHRP then return end
targetHRP = closestToMouse()
if not targetHRP then return end
loop = RunService.Heartbeat:Connect(function()
if not enabled then return end
if not myHRP or not targetHRP then return end
local cf = myHRP.CFrame
targetHRP.CFrame = cf + cf.LookVector * DISTANCE
targetHRP.AssemblyLinearVelocity = Vector3.zero
targetHRP.AssemblyAngularVelocity = Vector3.zero
end)
end
local function stop()
if loop then
loop:Disconnect()
loop = nil
end
targetHRP = nil
end
UserInputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == KEY then
enabled = not enabled
if enabled then
start()
else
stop()
end
end
end)No comments yet for this script.