Humanoid:MoveTo() with no timeout

I’m working with NPCs in my game and usally this isn’t a problem because there are no movements that take 8 seconds. But I have an NPC with a very slow walkspeed that just stops. After I remembered the 8 second timeout I started looking for solutions.

I found this code off of the developer hub but the problem comes when the movement is finished. After my NPC stops moving, it waits the 8 second timeout before triggering the callback function passed in thus making the NPC stand there for 8 seconds before doing the next thing.

How should I get around the timeout?

3 Likes

At the 8th second repeat the process?

1 Like

Refreshing the :MoveTo() on exactly the 8th second causes the whole thing to end and anything less causes the same issue.

function MoveNPC(Point, Character)
	local HRP = Character.HumanoidRootPart
	repeat
		wait()
		Character.Humanoid:MoveTo(Point)
	until (HRP.Position - Vector3.new(Point.X, HRP.Position.Y, Point.Z) ).magnitude <= 1
end

Maybe you can try that?

7 Likes

Success! Thank you.

30chars

1 Like

Thank you so much, this worked!