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

why does this script not work right?

Asked by
Benqazx 108
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
local player = script.Parent
function move()
local pointss = game.Workspace.Points:GetChildren()
for i =1, #pointss do
    print("Moving to: ", pointss[i].Position)
    player.Humanoid:MoveTo(pointss[i].Position)
end
end
while true do
    path = game:GetService('PathfindingService'):ComputeSmoothPathAsync(player.Torso.Position,game.Workspace.Finish.Position, 500)
    points = path:GetPointCoordinates()
    game.Workspace.Points:ClearAllChildren()
    for p = 1, #points do
        part = Instance.new('Part')
        part.CanCollide = false
        part.Anchored = true
        part.FormFactor = Enum.FormFactor.Symmetric
        part.Size = Vector3.new(1,1,1)
        part.Position = points[p]
        part.Parent = game.Workspace.Points
        move()
    end
    wait(1)
end

this script is a npc. i want the npc to go from 1 point to the next one until it is at its destination. this script is not working properly. it does make the npc to go from point to point. please help

Answer this question