Zombie Pathing in Tower Defense

I am writing a script for a tower defense game where the zombie walks from point to point.

Whenever I run the script, the zombie walks toward its next waypoint for about 5 second, before reaching its point it turns toward the next point.

I have tried adjusting the wait time on the script but the zombie then freezes at the waypoint for a few seconds. How do I get the zombie to make contact with the point then immediately head toward the next?

Image of Output printing Waypoint and Zombie position at MoveTo switch, path and zombie final position:

Summary

Script used to move Zombie:

Summary
local fein = script.Parent
local waypoints = game.Workspace.Board.PlayerPath.Waypoints

for waypoint=1, #waypoints:GetChildren() do
	fein.Humanoid:MoveTo(waypoints[waypoint].Position)
	fein.Humanoid.MoveToFinished:Wait()
	print('Waypoint Position:')
	print(waypoints[waypoint].Position)
	print('Zombie Position:')
	print(fein.HumanoidRootPart.Position)
end
1 Like

I never done anything like this in my life but
Maybe make it reach exact coordinates, then move to other coordinate
maybe thats the problem

MoveTo has an 8-second timeout. There’s a sample script (in the MoveToFinished section) in documentation (below link) that should give you an idea how to “refresh” MoveTo. Perhaps you can rewrite it to use Once instead of Connect.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.