Pathfinding // Waypoints not being created

Hey! A part of my script wont move a character to a specific point in the map and I’m not sure why.
Only thing I know is that it doesn’t create any waypoints; The waypoints table is empty. Please help.

local h,t = char.Humanoid,char.Torso
local p = pFS:CreatePath{WaypointSpacing = 2,AgentCanJump = true,AgentHeight = 5,AgentRadius = 3}
p:ComputeAsync(t.Position,Vector3.new(-28, 970, -27))
local w = p:GetWaypoints()
for i, way in pairs(w) do
	local wT = 0
	if way.Action == Enum.PathWaypointAction.Jump then
		h:ChangeState(Enum.HumanoidStateType.Jumping)
	end
	h:MoveTo(way.Position)
	repeat wT+=1 task.wait() until (t.Position - way.Position).magnitude < 4 or wT > 250
end
3 Likes

Make sure that you check p.Status to see if the path was computed succesfully.

It wasnt. I have no idea why.


That is where the NPC is suppost to go.

Can you print p.Path? If computing the path failed, we can see how it failed.

1 Like

I tried just now. States Path is not a valid member of instance.

1 Like

Sorry, I meant print(p.Status), not p.Path.

1 Like

Enum.PathStatus.NoPath is what it printed.

1 Like

Well, it did not manage to find a path. That is why no waypoints are created.

2 Likes

Is there any way to see why spesifically? I mean the doorway is wide open so I dont see why it cant.

1 Like

Try to get the position of the target without directly copying its position vector. Maybe this vector is wrong.

1 Like

Path still isnt being genetated; returning nopath.

1 Like

Replace your Vector3 with a part at the exact position you want the NPC to move to and use that in the script. See if the behaviour changes.
The reason I say this is that Vector3 is very high at 970 studs.

2 Likes

It’s hard to tell from the image you posted - Are you using Terrain in your game? This sometimes causes the navigation mesh to not align properly if there is a piece of terrain floating around that you thought was deleted etc.
Go to Studio Settings and turn on ‘Show Navigation Mesh’ in Visualization section. This will overlay your map with a mesh showing the area PathFinding uses. It should be level with your floors etc but can sometimes generate in unexpected areas (especially if there is terrain around - in my case it was thousands of studs below the actual map)

1 Like

I’m also getting empty waypoint arrays. I’ve checked the nav mesh, checked the path status (NoPath), and I doubt it has to do with actually moving humanoids, because it won’t move without an array of waypoints. The code I used for so long is only just now starting to act up, and it’s totally beyond me on as to why.

I tried fiddling with the agentparams, looked at the wiki, and still came up empty handed. Has Roblox done anything to pathfinding recently that would correlate to this issue?

1 Like

Right now i have the same problem, it used to work but suddenly the waypoint becomes empty

2 Likes