Enum.PathStatus.NoPath

Hi so I am trying make a r6 pathfinding script that goes to a part but Im getting this error when I print out the path status and the npc does not move

Enum.PathStatus.NoPath

my script

local PFS = game:GetService("PathfindingService")

function showPath(path)
	local waypoints = path:GetWaypoints()
	for _, waypoint in ipairs(waypoints) do
		local part = Instance.new("Part", game.Workspace)
		part.Shape = Enum.PartType.Ball
		part.Material = Enum.Material.Neon
		part.Anchored = true
		part.CanCollide = false
		part.Size = Vector3.new(1,1,1)
		part.Position = waypoint.Position
		game:GetService("Debris"):AddItem(part, 5)
	end
end

function createPath(target)
	print("WD")
	local agentParams = {
		AgentHeight = 2.5,
		AgentRadius = 2,
		AgentCanJump = true
	}
	print("AS")
	local path = PFS:CreatePath(agentParams)
	
	path:ComputeAsync(script.Parent.Torso.Position, game.Workspace.Part.Position)
	print('ASWQW')
	print(path.Status)
	if path.Status == Enum.PathStatus.Success then
		print("WDWDWDWWW")
		local wayPoints = path:GetWaypoints()
		print("WADWD")
		return path, wayPoints
	end
end



function main(target)
	if target then
		print("dsad")
		local path, waypoints = createPath(target)
		if path and waypoints then
			print("WW")
			for _, waypoint in ipairs(waypoints) do
				if waypoint.Action == Enum.PathWaypointAction.Jump then
					game.Workspace.NPC.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
				end
				script.Parent.Humanoid:MoveTo(waypoint.Position)
				print("sadas")
				script.Parent.Humanoid.MoveToFinished:Wait()
			end
		end
	end
end


main(game.Workspace.Part)

Ignore the print statements those are just for debugging

1 Like

Could we know which print statements are running?
Also a tip, try making the print statements as descriptive as possible, this way when you will try it tomorrow you will know what happens without needing to check the entire code over and over agin

image

1 Like

May it be because there’s obstructions in the oath?

I’m not an expert so I can’t help that much sorry :sweat_smile:

NoPath just means the Path Doesn’t exist according to Documentation.

1 Like

nope there is just a plain baseplate and the end pos is right in front of it

1 Like

so how would I try to fix this?

1 Like

When I tried to even print the waypoint table it was empty

1 Like

just read this and it helped

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.