Teleport Error Code 771

As the title suggests, I’ve been getting a lot of issues while attempting to use the Roblox TeleportService with ReservedServers. For those that don’t know, the error code 771 means that a non-existent server is trying to be reached. After recently releasing my game, I have gotten numerous reports about 771 errors. It appears to happen randomly, to individuals, maybe as much as 30%-40% of the time they attempt to teleport to a reserved server.

I’ve already looked at all the places I’m teleporting players to. They all have access open to everyone, they are the correct player count, there is nothing wrong with them. The weird part is that when teleporting a group of players, some players will teleport just fine while others will get the error. I don’t think wrapping it in a pcall would help as I’m pretty sure it takes the player out of the start place and cancels their connection to the server, then gives them the error, so there would be no way to retry.

If anyone has any sort of experience or advice with this it would be much appreciated. I’ve put down some relevant code below.

local reservedServer = TeleportService:ReserveServer(level.id)
				
for i,v in pairs(players) do
	local plrChar
	teleportData.players[v.Name] = {}
	teleportData.players[v.Name].data, plrChar = PlayerData.getPlayerData(v)
	teleportData.players[v.Name].character = plrChar
					
	coroutine.resume(coroutine.create(function()
		giveEffect(v)
		setLoadScreen:FireClient(v, level.level)
		done = true
	end))
end
				
teleportData.serverKey = reservedServer
	
repeat wait() until done
				
local loadScreen = game.ReplicatedStorage.Storage.LevelLoadScreen:Clone()
loadScreen.Frame.Destination.Text = "- "..level.level.." -"
loadScreen.Frame.DestinationShadow.Text = "- "..level.level.." -"
loadScreen.Frame.ImageTransparency = 0
loadScreen.Frame.ViewportFrame:Destroy()
				
for i,v in pairs(players) do
	PlayerData.removePlayer(v.Name)
end
			
teleportData = GameAnalytics:addGameAnalyticsTeleportData(playerIds, teleportData)
			
if level.level ~= "PvP" then	
	print(level.id, reservedServer, players)
	TeleportService:TeleportToPrivateServer(level.id, reservedServer, players, "SpawnPart", teleportData, loadScreen)
else
	TeleportService:TeleportPartyAsync(level.id, players, teleportData, loadScreen)
end

How do you know each of the coroutines is done? Is there more code somewhere resetting the flag to false? Otherwise it looks like the code is going through teleporting while those coroutines are probably still going. I wonder if that isn’t causing an issue?

There is more code, but it’s not relevant to the done flag. The flag is also in the local scope so it is reset every time this code is called. The coroutine only holds client sided effects and if it errored would not effect the actual teleport.

I assume you put the wait line in because you need those co-routines to complete before moving forward?

repeat wait() until done

This repeat wait should stop after the first co-routine finishes. Unless there is code somewhere else that changes this behavior. You could simply change done to a counter. Once it matches the number of players then you know each co-routine finished.

I ended up doing a lot of research into this and found a solution…

I created this place to continuously teleport a player to reserved server in order to reproduce the error as much as possible: https://www.roblox.com/games/5036765435/reserved-server-fail-test It tracks how many times you’ve teleported and how many times it failed and had to retry. I unlocked the place so you could look at how I was tracking things its very messy as I was just trying to test things quick. It appears I was wrong about the player being disconnected after getting the error, they were still connected to the start place. I will attach my code below for retrying…

local TeleportService = game:GetService("TeleportService")

local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local num = "None"
local fails = "None"


remote.OnServerEvent:Connect(function(client, value, value2)
	num = value
	fails = value2
end)

local teleportDestinations = {}

TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage)
	if teleportDestinations[player] then
		if teleportDestinations[player].reservedId then
			TeleportService:TeleportToPrivateServer(game.PlaceId, teleportDestinations[player].reservedId, {player}, nil, {num = num + 1, fails = fails + 1})
		end
	end	
end)

game.Players.PlayerAdded:Connect(function(player)
	player.OnTeleport:Connect(function(state, id, spawnName)
		print(state, id, spawnName)
	end)
	
	player.CharacterAdded:Connect(function(character)
		local reservedServer = TeleportService:ReserveServer(game.PlaceId)
		repeat wait() until num ~= "None" or not (game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0)

		if num == "None" then num = 0 end
		if fails == "None" then fails = 0 end
		
		teleportDestinations[player] = {reservedId = reservedServer}
		TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServer, {player}, nil, {num = num + 1, fails = fails})
	end)
end)

4 Likes

I started getting this same issue shortly after I responded to this post. I was going to attempt the same sort of solution. Simply following the teleport along and verifying it worked and then if not keep retrying the teleport until it does. I noticed the player never left the start place so I was thinking of simply checking to verify the player character was gone and if not try again. Glad you got it sorted :+1:

1 Like