RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Make my mouse cursor point to the nearest person when i hold right click"
-- local script local player = game.Players.LocalPlayer local mouse = player:GetMouse() local function findNearestPlayer() local nearestPlayer local nearestDistance = math.huge for _, otherPlayer in pairs(game.Players:GetPlayers()) do if otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") and otherPlayer ~= player then local distance = (otherPlayer.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude if distance < nearestDistance then nearestPlayer = otherPlayer nearestDistance = distance end end end return nearestPlayer end mouse.Button2Down:Connect(function() local nearestPlayer = findNearestPlayer() if nearestPlayer then local lookVector = (nearestPlayer.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).unit player.Character.HumanoidRootPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position + lookVector) end end)