RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a roblox script that loop follows the most close player"
-- server script local character = script.Parent local closestPlayer = nil game.Players.PlayerAdded:Connect(function(player) while wait(1) do closestPlayer = nil local closestDistance = math.huge for _, p in pairs(game.Players:GetPlayers()) do local distance = (p.Character.HumanoidRootPart.Position - character.HumanoidRootPart.Position).magnitude if distance < closestDistance then closestDistance = distance closestPlayer = p end end if closestPlayer then character.Humanoid:MoveTo(closestPlayer.Character.HumanoidRootPart.Position) end end end)