So, as kingdom5 said in the comments, yes there is a timeout of 8 seconds, so how can we get around this? We know that every 8 seconds that the WalkToPoint is not reached, the Function will time out. However, this also triggers another signal: Humanoid.MoveToFinished()
We can make the Humanoid:MoveTo() continue being played until the player reaches the goal (assuming they are unable to move freely)
What if we reach the part before the timer runs out? Well, we want to make sure we're close enough to the part for it to set off the MoveToFinished without setting it off too early, so we can use .magnitude to determine the distance from the part for this.
Server Script
local Part = workspace:WaitForChild("Part")
local stopper = false
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local human = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
human:MoveTo(Part.Position)
human.MoveToFinished:Connect(function()
if (root.Position - Part.Position).magnitude > 5 and stopper == false then
human:MoveTo(Part.Position)
else
stopper = true
end
end)
end)
end)
Where the part we are trying to reach is named "Part" within the Workspace
The "stopper" is to make sure that the (essentially a) loop will not play once its goal has been reached.
1 comment
Humanoid:MoveTo includes a timout of 8 seconds see https://developer.roblox.com/api-reference/function/Humanoid/MoveTo for more info.