while true do
task.wait(3)
self.target = self:findNearestTarget()
local path = PathfindingService:CreatePath()
local success, response = pcall(function()
path:ComputeAsync(self.creatureModel.HumanoidRootPart.Position, self.target.HumanoidRootPart.Position)
local waypoints = path:GetWaypoints()
if previousThread then
task.cancel(previousThread)
end
previousThread = task.spawn(function()
for _,waypoint in waypoints do
self.creatureModel.Humanoid:MoveTo(waypoint.Position)
self.creatureModel.Humanoid.MoveToFinished:Wait()
end
end)
end)
if not success then
warn(response)
end
end
I am attempting to have a thread that moves to the waypoints however when it starts to wait for MoveToFinished roblox throws the “attempt to resume dead coroutine” error internally with zero stack trace information. Is there an undocumented roblox feature that addresses this?