GetPlayerPlaceInstanceAsync API reference page has misleading example

So after messing around with GetPlayerPlaceInstanceAsync() I couldn’t figure out why it wasn’t returning the correct values. According to TeleportService | Roblox Creator Documentation
In the example given they have

local success, errorMessage, placeId, jobId = pcall(function()
	return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)

success, errorMessage, placeId, and jobId are the values returned by GetPlayerPlaceInstanceAsync() WITHOUT a pcall. (pic below of the api page)

The example given doesn’t seem to account for the success value returned by a pcall().
If you don’t account for the extra pcall success value, your variables won’t represent what you think they might.
In the screenshot below you would expect jobId to be “4” but it actually prints “3” which is what placeId should be.
image

A correct example of using this with a pcall could be:

local teleSuccess, teleErrorMessage, placeId, jobId
local success, errorMessage = pcall(function()
     teleSuccess, teleErrorMessage, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)

if success and teleSuccess then
     -- do tele stuff
end
9 Likes