MoveTo doesn't work correctly

So I am trying to make a tower defense game and I am stuck with one problem for 2 hours , idk how to solve it , so basically I want the zombies to get thru every waypoint , but the slow ones are not going all the way and touching the waypoints , they are going 75% of the way and they go to the other one without touching the correct waypoint


something like this

here is the code that makes them move:

function mob.Move(mob, map)
	local humanoid = mob:WaitForChild("Humanoid")
	local waypoints = map.Waypoints

	for waypoint=1, #waypoints:GetChildren() do
		mob.MovingTo.Value = waypoint
		humanoid:MoveTo(waypoints[waypoint].Position)
		humanoid.MoveToFinished:Wait()
	end
end

I rlly don’t know how to solve this , I am losing interest in continuing this game , I would appreciate some help , thank you for your time!

MoveTo stops working after around 7 seconds and since your zombie move slow, the zombies might not reach the waypoint before MoveTo stops working becaude they are too slow.

1 Like

Should I make more waypoints? and use the same script?

I would suggest Tweening them to waypoints since Humanoid for Enemies in a TD games cause a lot of lag when there a bunch of enemies.

alr then , thank you bro , good luck

Also you can use TweenService 2 to tween the enemies as it’s good for your use case.

1 Like

To be precise the ‘MoveTo’ method of ‘Humanoid’ instances has a timeout of eight seconds, after this timeout the Humanoid's ‘MoveToFinished’ event/signal will be fired, passing/returning a value of false indicating that the ‘Humanoid’ didn’t reach its intended goal.