Path.Status says Enum.PathStatus.NoPath why?
local pathfindingService = game:GetService("PathfindingService")
local pointModel = Instance.new("Model")
pointModel.Name = "Points"
pointModel.Parent = game.Workspace
function visualizePath(path)
-- clear old path visualization
pointModel:ClearAllChildren()
-- calculate new visualization
local points = path:GetPointCoordinates()
for _, point in ipairs(points) do
local part = Instance.new("Part")
part.FormFactor = Enum.FormFactor.Custom
part.Size = Vector3.new(1,1,1)
part.Position = point
part.Anchored = true
part.CanCollide = false
part.Parent = pointModel
end
end
function GetPath ()
local start = game.Workspace.Start.Position
local target = game.Workspace.End.Position
local path = pathfindingService:ComputeRawPathAsync(start, target, 500)
visualizePath(path)
-- Check to see if the path was computed correctly
print (path.Status)
if path.Status == Enum.PathStatus.FailStartNotEmpty or path.Status == Enum.PathStatus.FailFinishNotEmpty then
print("Compute failed")
return {}
end
return path:GetPointCoordinates()
end
wait ()
while true do
wait (9)
GetPath()
end