Why are npcs not following the specific path?


As you can see here, the npcs should be walking to the white blocks 1 by 1, but instead they just ignore some white blocks.
The script that controls the npcs movement:

function move(Entity)
	for i, v in ipairs(nodes:GetChildren()) do
		Entity.Humanoid:MoveTo(v.Position)
		Entity.Humanoid.MoveToFinished:Wait()
	end
end

( nodes is the file that contains all the white blocks ), in the script it should move to the next node, once finished then it waits, and moves to another white block again.
Anyone know why the npc walks outside of the path?

Are the nodes in a folder? The nodes might be out of order when you call GetChildren() which is why the NPC skips over some of them. You could try organizing them in a table

nodes = {
"Node1",
"Node2",
--etc
}

and then looping through the table and calling nodes:FindFirstChild(v) to get the nodes in order

1 Like

The nodes are parts in a folder in workspace, and I found out that they ignore some of the nodes, it doesn’t go from node a to node z, it just goes from node b to node d and then node h something like that.