Something's weirdly wrong with this simple pathfinding script

local pathfindingservice = game:GetService("PathfindingService")

local path = pathfindingservice:CreatePath()
path:ComputeAsync(workspace.Part1.Position, workspace.Part2.Position)

local pathwaypoints = path:GetWaypoints()

for _, waypoint in pairs(pathwaypoints) do
		print(waypoint.Position)
end

It just doesn’t print the waypoints. Could anybody tell me what exactly is going on? My head cant get around this not working, despite it being so simple, and after looking at other pathfinding scripts that work and trying to apply that same logic, nothing seems to work.

No path was computed most likely. You could try printing the path’s Status property to affirm that.

You can try turning on NavMesh Visualization under Studio Settings to see if there’s anything obstructing the path between the two parts.

1 Like

It prints “NoPath”, which i assume means no path was created. Could you tell me how to work around this? I don’t know why it isnt computing the path, Part1 and Part2 are differently shaped parts not too far from eachother sat in the workspace, so i’m not sure that it’s those, and i’m not sure that it’s that im computing it too fast, as other scripts of pathfinding in studio work instantly, but for some reason, this does not.

bruh i changed the size of part2 and voila it works now
there’s something up with trying to make a path with a part sized at a vector3 of 4, 8.424, 7.96 i guess
a position of -0.353, 4.212, -31.295 is fine though

1 Like

The Y positional difference may have been too much, so it failed to compute a path.

1 Like

As someone who often works with pathfinding for fun: This is true.
Most cases the height of a part can easily mess up with pathfinding, especially if the objective is getting on top of the part.
Another thing that often breaks pathfinding is object orientation, sometimes a path wont be able to be generated if an object is weirdly rotated, even if only at the X axis.

1 Like

Ah, i see. Thank you for the technical explanation.

1 Like