I'm trying to make an NPC go around using waypoints (1-9). It does well the first 4 waypoints and starts going towards the 5th but half the way there the NPC starts going to waypoint 6. My code:

local waypoints = game.Workspace.Paths:GetChildren()

for waypoint=1, #waypoints do
	script.Parent:MoveTo(waypoints[waypoint].Position)
	script.Parent.MoveToFinished:Wait()
end

2 comments

1

Try getting each of the waypoints named in order for example: waypoint1, waypoint2, waypoint3, waypoint4, waypoint5, waypoint6, waypoint7, waypoint8, waypoint9.

0

Fixed, thanks!