How would you move the npc in a more easier way

Hey, I have preset checkpoints for a NPC to move, the problem is that the way I am moving them doesn’t look good. I would need to move them to checkpoint 1 - 10. How would I do this without doing what I just did?
Screenshot 2023-10-09 180208

Id use a for loop in this case.

local Nodes = workspace.Nodes -- Can also be a folder. Im using a model in this case.
local Iters = #Nodes:GetChildren() -- Short for iterations. The amount of times were gonna loop which will be 4 in this case since we only have 4 parts in the model.
local Hum = workspace.Rig.Humanoid




for i = 1, Iters do
	local Node = Nodes:FindFirstChild("a"..i) 
	
	Hum:MoveTo(Node.Position,Node)
	Hum.MoveToFinished:Wait()  -- Use whatever wait method you want. I used "MoveToFinished" which waits until the humanoid has finished walking to its destination.
end

All were doing is looping through all of the items inside the array and grabbing them from the model with “FindFirstChild” which will grab the instance with the name that matches.

1 Like

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