TeleportAsync allows for teleporting to a server with ReservedServerAccessCode of nil

If a ReservedServerAccessCode is nil, and set in a TeleportOptions object, players teleported will be placed in a broken server. After teleport, players won’t see any instances in workspace. Within a few seconds they’ll be kicked for one of three reasons:

  1. Roblox has shut down this server for maintenance
  2. Client initiated disconnect
  3. Player data nil, player kicked (this is unique to experiences using ProfileService)

Steps to Reproduce:

  1. Create a TeleportOptions instance
  2. Set the ReservedServerAccessCode to nil
  3. Teleport players using TeleportAsync API

Expected behavior

I would expect an error to be thrown that can be caught in a Pcall or Promise.

2 Likes

Thanks for filing this. We’ve logged a bug for it in our internal database

We tried reproducing the issue with a minimal example

print("Hello world!")

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)
print("someone joined")
wait(3)
--= create teleport options with nil reserve server
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ReservedServerAccessCode = nil

TeleportService:TeleportAsync(game.PlaceId, {player}, teleportOptions)
end)

and got an error

Unable to assign property ReservedServerAccessCode. string expected, got nil

This seems to be working as expected. Can you add any more detail?

Looks like I left out some important details on this. Here’s the code that was calling TeleportAsync.

local success, teleportOptions = pcall(function()
	return Create "TeleportOptions" {
		ReservedServerAccessCode =
			if (runContext == Enums.ServerRunContext.WorldPlay) then
				reservedServers.WorldPlayAccessCode
			else
				reservedServers.WorldEditAccessCode
	}
end)

-- If something went wrong, bail
if (not success) then
	return {
		Error = teleportOptions
	}
end

TeleportService:TeleportAsync(game.PlaceId, {player}, teleportOptions)

What failed in my experience

The Create keyword is a wrapper for Instance.new(). After some investigation, here’s what I figured out. The Create library does some fancy error handling and default value setting. So, the inline if statement evaluated to nil, which Create caught, and set as a blank string. Meaning, we have a not-null TeleportOptions with a ReservedServerAccessCode of “”.

Steps to Reproduce

I was able to reproduce this by using your code, and assigned ReservedServerAccessCode to ""

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)
	print("someone joined")
	wait(3)
	--= create teleport options with nil reserve server
	local teleportOptions = Instance.new("TeleportOptions")

    -- set this to a blank string
	teleportOptions.ReservedServerAccessCode = ""

	TeleportService:TeleportAsync(game.PlaceId, {player}, teleportOptions)
end)

When running this in-game, we get this error.

CleanShot 2023-04-12 at 14.54.38

2 Likes

Going back to this - we believe this error should be gone now, we have added a check on our end too to check empty string as well. Feel free to post if the issue happens again!

2 Likes