Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make my npc follow the parts to the desired destination?

while true do local path = game:GetService('PathfindingService'):ComputeRawPathAsync(script.Parent.Torso.Position, game.Workspace.finish.Position,300) local points = path:GetPointCoordinates()

game.Workspace.Points:ClearAllChildren()


for p = 1,#points do
	part = Instance.new('Part')
	part.FormFactor = Enum.FormFactor.Symmetric
	part.CanCollide = false
	part.Size = Vector3.new(1,1,1)
	part.Position = points[p]
	part.Anchored = true
	part.Parent = game.Workspace.Points
	
end


script.Parent.Humanoid:MoveTo(part.Position)

wait()

end

1 answer

I am not so sure but I think you forgot your variable.

local points = game.Workspace.Points:ClearAllChildren() --Forgot variable


for p = 1, #points do
    part = Instance.new('Part')
    part.FormFactor = Enum.FormFactor.Symmetric
    part.CanCollide = false
    part.Size = Vector3.new(1,1,1)
    part.Position = points[p]
    part.Anchored = true
    part.Parent = game.Workspace.Points

end


script.Parent.Humanoid:MoveTo(part.Position)

wait()

This discussion is preserved as it was. New answers, comments, and votes are closed.