RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a script that makes me follow a close player"
-- local script local Players = game:GetService("Players") local Player = Players.LocalPlayer local Character = Player.Character local Humanoid = Character.Humanoid local closestPlayer while true do local closestDistance = math.huge for _, player in pairs(Players:GetPlayers()) do if player ~= Player then local playerCharacter = player.Character if playerCharacter then local playerHumanoidRootPart = playerCharacter:FindFirstChild("HumanoidRootPart") local distance = (Humanoid.RootPart.Position - playerHumanoidRootPart.Position).magnitude if distance < closestDistance then closestDistance = distance closestPlayer = player end end end end if closestPlayer and closestPlayer.Character then local target = closestPlayer.Character:FindFirstChild("HumanoidRootPart") if target then Humanoid:MoveTo(target.Position) end end wait(1) end