NPC wont move to certain points

npc moves fine to point2 and point3 but after that when he needs to move to point4 he just stops moving

script:

script.Parent.Humanoid:MoveTo(game.Workspace.Outside2.Position)

script.Parent.Humanoid.MoveToFinished:Connect(function()

script.Parent.Humanoid:MoveTo(game.Workspace.Outside3.Position)
end)

script.Parent.Humanoid.MoveToFinished:Connect(function()
script.Parent.Humanoid:MoveTo(game.Workspace.Outside4.Position)
end)

script.Parent.Humanoid.MoveToFinished:Connect(function()
script.Parent.Humanoid:MoveTo(game.Workspace.Outside5.Position)
end)

script.Parent.Humanoid.MoveToFinished:Connect(function()
script.Parent.Humanoid:MoveTo(game.Workspace.Outside6.Position)
end)

script.Parent.Humanoid.MoveToFinished:Connect(function()
script.Parent.Humanoid:MoveTo(game.Workspace.Outside7.Position)
end)

1 Like

Does it even start to move to Outside4, or does it only move part way?

no, its just staying there like the script finished

Try reordering the sequence of events to see if it’s code-related. It could be something about the destination or path it’s taking that’s causing an issue.

just did, its code-related for some reason

you may need to add task.wait() between the code?

Oh, it might be because you have multiple MoveToFinished events. Try only using one event. Maybe this will work:

local destination = 1
local endDestination = 7
script.Parent.Humanoid.MoveToFinished:Connect(function()
   destination += 1
   if destination <= endDestination then
      script.Parent.Humanoid:MoveTo(workspace["Outside"..destination].Position)
   end
end)
script.Parent.Humanoid:MoveTo(workspace["Outside"..destination].Position)

⁽ⁱ ᵈⁱᵈⁿ’ᵗ ᵗᵉˢᵗ ᵗʰⁱˢ⁾

it seems to work but the npc skipped the fourth destination and it skips to the next destination even tho the npc diddnt reach the part yet

still does not want to work :confused:

I just reviewed the documentation and it says,

The reach goal state of a humanoid will timeout after 8 seconds if it doesn’t reach its goal. This is done so that NPCs won’t get stuck waiting for Humanoid.MoveToFinished to fire. If you don’t want this to happen, you should repeatedly call MoveTo so that the timeout will keep resetting.

Throw a loop into the mix and it should be good to go. Alternatively, you could add more points if you don’t want to do that.

The script becomes an endless loop after the script.Parent.Humanoid:MoveTo(game.Workspace.Outside3.Position) function. Now, when the NPC finishes the movement to Outside3, it just fires the MoveFinished event that is above it, not below, since the one above was defined earlier.