RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a script that makes you move to the most close player using path finding"
local pfs = game:GetService("PathfindingService") local player = game.Players.LocalPlayer local closestPlayer = nil for _, otherPlayer in pairs(game.Players:GetPlayers()) do if otherPlayer ~= player then if not closestPlayer or (otherPlayer.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude < (closestPlayer.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude then closestPlayer = otherPlayer end end end if closestPlayer then local path = pfs:CreatePath() path:ComputeAsync(player.Character.HumanoidRootPart.Position, closestPlayer.Character.HumanoidRootPart.Position) for _, waypoint in pairs(path:GetWaypoints()) do player.Character.Humanoid:MoveTo(waypoint.Position) player.Character.Humanoid.MoveToFinished:Wait() end end