Error 773 Teleport to a restrict place

Hi! Can I get some help?

It says error 773, that I cant teleport because acess Code for reserved server is not valid (Unauthorized).

I tried to use Creator Hub Permissions, using TeleportAsync(), teleportOptions, TeleportToPrivateServer(), ReserveServer().

Code that creates the server for the player who creates (works)

serverTeleportEvent.OnServerEvent:Connect(function(player, serverName)
	print("Criando server for " .. player.Name)

	local teleportOptions = Instance.new("TeleportOptions")
	
	teleportOptions.ShouldReserveServer = true

	local success, result = pcall(function()
		TeleportService:TeleportAsync(placeId, {player}, teleportOptions)
	end)

	if success then
		print("Creating and teleporting to server")
	else
		warn("Fail creating server: " .. result)
	end
end)

Code that teleports the player that clicks “Join” button (joining another player’s server) (doesnt work (error 773))


teleportEvent.OnServerEvent:Connect(function(player, privateServerCode)
	if not privateServerCode then
		warn("Erro: Código do servidor inválido")
		return
	end
	
	local teleportOptions = Instance.new("TeleportOptions")
	
	teleportOptions.ReservedServerAccessCode = privateServerCode

	local success, result = pcall(function()
		TeleportService:TeleportAsync(placeId, {player}, teleportOptions)
	end)

	if success then
		print(player.Name .. " foi teleportado para " .. privateServerCode)
	else
		warn("Erro ao teleportar jogador:", result)
		warn(privateServerCode)
	end
end)

I’ve been trying solutions for hours and hours, but they doesnt work. The code error is 773, the output says: teleport failed because acess code for reserved server is not valid (unauthorized).

I managed to replicate the issue, and I think it’s due to the privateServerCode you’re passing.

Instead of using:

teleportOptions.ShouldReserveServer = true

I use:

local reservedServerCode = TeleportService:ReserveServer(placeId)
teleportOptions.ReservedServerAccessCode = reservedServerCode

It seems like you’re not using TeleportService:ReserveServer(), so the server was never actually reserved.

1 Like

Thank you for replying!

I will test it right now and reply to you soon, thank you.

So, I tried it. The player who created the server before my post could already teleport, but no the players who tried to join thei server. With your change, it is the same, the players who try to join the other player server still cant join, the message is the same.
But I want to tell you something, in this part of code that i’ll show right now, the other place sends the privateserverid, I share it to the Hub and it tries to teleport the player there, but it says the acess code is not valid.

the code i’m talking about:

teleportEvent.OnServerEvent:Connect(function(player, privateServerCode)
	if not privateServerCode then
		warn("Erro: Código do servidor inválido")
		return
	end
	
	local teleportOptions = Instance.new("TeleportOptions")
	
	teleportOptions.ReservedServerAccessCode = privateServerCode

	local success, result = pcall(function()
		TeleportService:TeleportAsync(placeId, {player}, teleportOptions)
	end)

	if success then
		print(player.Name .. " foi teleportado para " .. privateServerCode)
	else
		warn("Erro ao teleportar jogador:", result)
		warn(privateServerCode)
	end
end)

The code you told me to make the edits (i did):

serverTeleportEvent.OnServerEvent:Connect(function(player, serverName)
	print("Criando servidor para " .. player.Name)
	
	local sucessR, resultR = pcall(function()
		return TeleportService:ReserveServer(placeId)
	end)
	
	local reservedServerCode
	
	if sucessR then
		reservedServerCode = resultR
		print("CONSEGUIU RESERVAR!", resultR)
	else
		print("NAO CONSEGUIU RESERVAR:", resultR)
	end

	local teleportOptions = Instance.new("TeleportOptions")
	
	teleportOptions.ReservedServerAccessCode = reservedServerCode

	local success, result = pcall(function()
		TeleportService:TeleportAsync(placeId, {player}, teleportOptions)
	end)

	if success then
		print("Criando e teleportando pro servidor")
	else
		warn("Falha ao criar servidor: " .. result)
	end
end)

Thank you for helping me, God bless! Waiting for your reply.

There’s a small chance that the reserved server code can only be used once, but I don’t think that’s the case because there is nothing in the documentation.

I suspect that the code being sent isn’t the same one that was originally generated. To fix this, you could try one of these approaches:

1. Store the Reserved Codes Temporarily:

  • Create a table where each reserved server code is stored with the player’s UserId as the key.
  • When another player wants to join, they send the UserId of the player who created the server, and you can fetch the correct reserved code from the table.

2. Use SetTeleportData:

You can pass the reserved server code directly through teleport data like this:

local teleportData = { privateServerCode = 123456 }

local teleportOptions = Instance.new("TeleportOptions")
teleportOptions:SetTeleportData(teleportData)

This way, when the player joins the destination place, the server can retrieve the code and use it again if needed.

3. Follow a Tutorial:

If you prefer, I used Suphi’s video to learn how to handle TeleportService:

1 Like

Thanks for replying, I see you are smart. I’ll try it, and update you soon, Thank you buddy!

You saved me, you saved my stress, bro I appreciate so much, I hope you receive ur help in double. It worked. If I could give you any gift, retribution, I’m down. You deserve so much good, thank you! God bless your life. U the best!

1 Like