while wait(2.8) do
path = PFS:ComputeSmoothPathAsync(Droid.Head.Position, Droid.Head.PathTarget.Position, 512) -- raw
pathc = PFS:ComputeSmoothPathAsync(Droid.Head.Position, Droid.Head.PathTarget.Position, 512):GetPointCoordinates()
for i,v in pairs(pathc) do
local Part = Instance.new("Part", Droid.Head)
Part.CFrame=CFrame.new(v)
Part.Transparency = 0
Part.Color = Color3.new(0.2, 0, 1)
Part.Size = Vector3.new(1, 1, 1)
Part.Anchored = true
Part.CanCollide = false
Part.Locked = true
Part.Name = 'Path'
Part.Touched:connect(function(hit)
Part:Destroy()
end)
if path.Status == Enum.PathStatus.Success then
Part.Color = Color3.new(0, 1, 0) -- green
elseif path.Status == Enum.PathStatus.ClosestNoPath then
Part.Color = Color3.new(1, 0, 0) -- red
elseif path.Status == Enum.PathStatus.ClosestOutOfRange then
Part.Color = Color3.new(0.5, 0.75, 0) -- yellow
elseif path.Status == Enum.PathStatus.FailStartNotEmpty then
Part.Color = Color3.new(0.5, 0, 0.5) -- purple
elseif path.Status == Enum.PathStatus.FailFinishNotEmpty then
Part.Color = Color3.new(0.5, 0, 0.5) -- purple
end
Debris:AddItem(Part, 20.8)
end
for i, v in pairs(pathc) do
Humanoid:MoveTo(v)
repeat
distance = (v - Droid.Head.Position).magnitude
wait()
until distance < 2
end
end
Basically what the above script does is compute a path, make a part trail over it, and use a for loop + repeat loop to make a droid NPC follow the path.
The problem is the repeat loop yields the entire while loop, so it wont try to compute another path until it's gotten to the target of the first one.
This'll sound very requesty, but bear with me as I have no idea how to do this without breaking it.
What i need it to do is be able to make the droid stop following the path it's on without breaking the loop, compute a new path to PathTarget, then make the droid follow the new path.

2 comments
This might help, use this instead of looping: http://wiki.roblox.com/index.php?title=API:Class/Humanoid/MoveToFinished
That doesent change anything about this particular yield