Path:ComputeAsync().Status = nil?

local PathfindingS = game:GetService('PathfindingService')
	local Path = PathfindingS:CreatePath()

print(Path:ComputeAsync(Vector3.new(0,2,0),Vector3.new(10,2,10)).Status)

LocalScript:4: attempt to index a nil value

Path:ComputeAsync(Vector3.new(0,2,0),Vector3.new(10,2,10))

ComputeAsync modifies Path and returns nil. Effectively, your code tries to index nil, not the Path itself.

Think of Path:ComputeAsync() as analogous to Model:MoveTo(). It doesn’t make sense to do Model:MoveTo(Vector3.new()).Name, so it doesn’t make sense to do Path:ComputeAsync(Vector3.new(0,2,0),Vector3.new(10,2,10)).Status either.

You should get its status on a separate line.

local PathfindingS = game:GetService('PathfindingService')
local Path = PathfindingS:CreatePath()
Path:ComputeAsync(Vector3.new(0,2,0),Vector3.new(10,2,10))
print(Path.Status)

image and I have been tearing hair from my head wondering what is wrong.

We seriously need more documentation



Thank you for your response!

I agree - documentation for PathfindingService is a little incomplete. However, in this case you can follow standard debugging procedures + use the DevHub to figure out what’s going wrong.

The error message said you were trying to “index a nil value”:

  • “index” means where you did .Status
  • “nil value” means that Path:ComputeAsync(...) returned nil

You can look at what (if anything) an API function returns by taking a look on the DevHub. Here, the appropriate page is Path | Documentation - Roblox Creator Hub.


You can see there at the bottom under the “Returns” heading it says “void”. This means that it does not return anything, which explains why you got the error that you did.

That’s exactly what I do, I looked on the DevHub and thought it was a mistake that it returns nothing since it is lacking so many pieces of crucial information, I would assume that the specific DevHub page is neglected.

All of this was caused by me trying to shorten code. Thankfully it’s now solved by XAXA*



Thank you for your response.