Roblox Studio does not throw a proper error when teleporting using TeleportAsync

Reproduction Steps

Place the following code in a server script somewhere it will run like in ServerScriptService:

local teleportService = game:GetService("TeleportService")

teleportService.TeleportInitFailed:Connect(function(failedPlayer, teleResultItem, errMsg, placeId, teleOptions)
	print("TeleportInitFailed!", errMsg, teleResultItem)
end)

wait(5)
local player = game.Players:GetPlayers()[1]
local success, msg = pcall(function() return teleportService:TeleportAsync(233195390, {player}) end)
warn("success:", success, " message (if any):", msg)

Then, playtest in Roblox Studio.
Wait 5 seconds and observe the output.

Expected Behavior

The orange warning in the output should say something along the lines of
success: false message (if any): TeleportService:TeleportPartyAsync error: The player[17967658] with wrong session.
like it does with TeleportPartyAsync.

Actual Behavior

The following warning is posted to the output:
success: true message (if any): Instance

The pcall does not see any error and believes the player has successfully teleported so my code cannot handle this.
This makes testing code that is meant to handle real-world teleport errors difficult as this is normally the most reliable way to do so.

I understand that right after this a red error appears saying exception while signaling: Cannot Teleport in the Roblox Studio. but this is a lie as it does not actually throw an exception. There is no error for my code to detect. Note that not even TeleportInitFailed fired. There is no way for me to detect that something has gone wrong in-code.

I understand that this won’t have any real-world impact as no users are playing in Roblox Studio, but this does interfere with the development process and should be a simple fix to make testing teleport error handling easier for devs.

Workaround

Use TeleportPartyAsync when testing instead.

Issue Area: Studio
Issue Type: Other
Impact: Low
Frequency: Constantly

4 Likes

Thanks for the report! We’ll take a look.

3 Likes

So sorry for the late response, is this still an issue? We’ve marked it as done.

Yes, it is still an issue. If you use the code snipped I provided before you’ll find the pcall still doesn’t receive an error. TeleportInitFailed does at least fire now which is nice, but the pcall is what I was really worried about.

Ok, I pinged the engineers, hang tight!

1 Like

This is actually how the feature is supposed to work. When you call the teleportService, there are multiple steps for teleporting a player.
‘pcall’ returns False if the call fails initial validations. However, if it fails later, we emit the event ‘TeleportInitFailed’ since the method has already returned success.
We are sorry you are having trouble, but this was an intended design for this feature.

Why would this be intended if all validation checks are part of the TeleportAsync process?

1 Like