function move(Entity)
local count = 1
for i = 1, #game.Workspace.Map.Nodes:GetChildren() do
if Entity:FindFirstChild("Humanoid") then
--print(count)
if count == 7 then
Entity.HumanoidRootPart.Position = nodes["7"].Position
task.wait()
count = 8
else
print(count)
Entity.Humanoid:MoveTo(nodes[count].Position)
Entity.Humanoid.MoveToFinished:Wait()
count = count + 1
end
end
end
end
This function moves a npc from node 1 to node 25, and it tps the npc from node 6 to node 7. However after tping the npc from node 6 to node 7, the “count” variable keeps jumping to different numbers. I can’t seem to find out why.
Help will be appreciated !