the scipt:
local PathfindingService = game:GetService("PathfindingService")
local humaniod = script.Parent:WaitForChild("Humanoid") local body = script.Parent:WaitForChild("HumaniodRootPart") or script.Parent:WaitForChild("Torso")
local PlayerLocked
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local function NearestPlayer()
local distance = 1000000000000000000000
local PlayerLocked2
for i, Player in pairs(player.Character) do
if Player.Character then
local distance2 = (Player.Character.HumaniodRootPart.Position - script.Parent.HumaniodRootPart.Position).Magnitude
if distance2 < distance then
distance = distance2
PlayerLocked2 = Player.Position
PlayerLocked = PlayerLocked2
end
end
end
local path = PathfindingService:CreatePath()
wait(0.5)
path:ComputeAsync(body.Position, PlayerLocked)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
humaniod:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
humaniod:ChangeState(Enum.HumanoidStateType.Jumping)
end
humaniod.MoveToFinished:Wait()
end
end
end)
end)

1 comment
its a a little weird some of the code is not converted so read from the top