Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Jumbuu 110
7 years ago

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

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

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()

Ad

Answer this question