local function FollowPath(masterpath, coord)
for i, v in pairs(coord) do
Droid.Humanoid:MoveTo(v)
local distance
repeat wait()
distance = (v - Droid.Head.Position).magnitude
print(distance)
until distance < 2
end
end
This works as expected, with the droid repeatedly moving to each of the coordinates and moving back to it if it's moved off course. However, if it's not near the path for ~8 seconds, it just stops moving and will only start following the path again if I manually push it back to where it was before.
Is there a way to prevent this, or at least have a function that tells it to move back to the path again if it stops moving?
EDIT: The whole script by request of europe EDIT2: Solved by KoreanBBQ
Droid = script.Parent.Parent
PFS = game:GetService('PathfindingService')
PFS.EmptyCutoff = 0
Debris = game:GetService('Debris')
local function FollowPath(masterpath, coord)
for i, v in pairs(coord) do
Droid.Humanoid:MoveTo(v)
local distance
repeat wait()
distance = (v - Droid.Head.Position).magnitude
print(distance)
until distance < 2
end
end
masterpath = PFS:ComputeSmoothPathAsync(Droid.Head.Position, Droid.Head.PathTarget.Position, 512)
coord = masterpath:GetPointCoordinates()
for i, v in pairs(coord) 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.Material = Enum.Material.Neon
end
spawn(function() FollowPath(masterpath, coord) end)
