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

Pathfinding script goes to my last location then me?

Asked by 8 years ago

I understand what's happening but I do not know how to stop it, any help?

This is the script that is located in the NPC, as you can tell, it's non-local. It completely works, the only problem is that it goes to my last location then to me. If you want a visual representation of what's happening, look here.

end
local path
local torso = script.Parent.Torso
local human = script.Parent.Humanoid
local players = game.Players
local pathfindingService = game:GetService("PathfindingService")
pathfindingService.EmptyCutoff = 0.01
local dist = 20
while wait() do
for _,v in pairs (game.Workspace:GetChildren()) do
    if players:FindFirstChild(v.Name) and v.Humanoid then
        if math.abs((v.Torso.Position - torso.Position).magnitude) <= 5000 then
            local wend = v.Torso
                path = pathfindingService:ComputeSmoothPathAsync(script.Parent.Torso.Position,wend.Position,500)
                Plix = path:GetPointCoordinates()
                    for _,plox in pairs (Plix) do
                    human:MoveTo(plox)
                    human.MoveToFinished:wait()
                    end
        end
    end
end
end
0
You're waiting for the MoveTo to finish, so it will wait until it gets to your last location and then go to your current location. Get rid of line 18 (human.MoveToFinished:wait()) and it should be fine. Spongocardo 1991 — 8y
0
The thing is, if I get rid of it, it'll follow me just by following the last point, so how do I fix that? HungryJaffer 1246 — 8y

Answer this question