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

3 comments

0

Be more descriptive on the problem and what you have tried, you pretty much just pasted in a whole script for us and expected us to solve the problem.

0

You are also using deprecated items, those being ComputeRawPathAsync and FormFactorPart.FormFactor

0

Well read it: Enum.PathStatus.NoPath. No path was found. You are also using deprecated pathfinding service functions.