Stuck in an infinite teleport loop when trying to teleport a player to a reserved server

Hello developers, This problem has been giving me a lot of trouble lately and all attempts to fix it have not worked.

When someone starts a new session of a lobby in my game, The data for that lobby becomes session-locked.

However, If the player is put into a new server either due to an error or Roblox’s own automatic server allocation then the game should automatically attempt to teleport the player to the correct server using the saved Reserved Server Access Code.

This has not worked at all as the teleport request will repeatedly put me in the wrong server which causes an infinite teleport loop (and a lot of client lag) until the client is automatically disconnected. (Client initiated disconnect.)

I have no idea what to do at this point as all of my attempts have failed completely.

The part of my script that handles this automatic teleport is below:

		local teleportOptions ="TeleportOptions")
		teleportOptions.ReservedServerAccessCode = _lobbyData.reservedCode
		local teleportData = {
			joinedLobbyName = lobbyDataModule.getLobbyName()
		for _, player in game.Players:GetChildren() do
			teleportService:TeleportAsync(game.PlaceId, {player}, teleportOptions)

Any help with this is greatly appreciated,
Thanks, MBroNetwork.

Edit: If the lobby is already full then it will throw the player back into the main menu place.

This issue is still unresolved as of writing, All of my efforts have just failed completely.

I store the reserved server into a memory store, along with the public server instance id. Are you doing the same?

I’m currently storing the reserved server into the datastore for the lobby.

That might be the problem. Datastores take several seconds to store data compared to memory stores, and during the save process you teleport and then the server shuts down, leaving no time to save the data.

You may prefer teleporting the player in the reserved server that way. See TeleportService | Roblox Creator Documentation.

Exemple from Docs :

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

local code = TeleportService:ReserveServer(game.PlaceId)

local players = Players:GetPlayers()

TeleportService:TeleportToPrivateServer(game.PlaceId, code, players)
-- You could add extra arguments to this function: spawnName, teleportData and customLoadingScreen

PS : Note that based on TeleportOptions | Roblox Creator Documentation your approach should work. Maybe this part of the script is triggered even when the player joins the right server. Do you check that the user is not already in reserved server before teleporting him?
local isReserved = game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0 from TeleportService | Roblox Creator Documentation

It actually might be that which is causing it, I was already planning on using Memory Stores but have no clue where to start with them.

Edit: I’m not 100% certain that this is causing it as the reserved server access code is saved correctly according to all my debugging efforts thus far.

I did notice some unusual behavior with my reserve system which shouldn’t occur where it just created a public server instead of a reserved/private server like it’s intended to, It’s possible that the private server teleport is valid but the actual server that’s active is not.

I do check if the server is a reserved server, However, I’m noticing some very unusual behavior where the server seems to just be a standard public server instead of it being a reserved server like it’s supposed to be.

I’ve fixed the issue, I recently changed the way that the Reserved Server Access Code is stored to a variable in the script that handles reserving a server.

However, Because I forgot to change the function for reserving a new server to update this variable, The server that was created was a standard server since there was no valid code to use which then also caused the automatic teleport to infinitely loop due to there being no reserved server to teleport to in the first place.

Thank you to those of you who tried to help me with this issue, I appreciate it a lot.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.