How do I check for a already existing reserved server?

I’ve seen the other posts on this but I kind of need something specific and simple to understand because I just learnt about reserved servers.

I have a menu in my game which teleports you to the actual game place in the same universe and private servers don’t work because it just makes a private server for the menu and it just teleports you to the game in a public server. How do I use reserved servers here and let other players join the private server and be able to join the same key for the existing reserved server if there is a existing reserved server. ALSO I have a admin panel which you can use in your private server so how would it send the private server owner to the reserved server. I know this is a long request but it would be a big help, Thanks!

Using the TeleportService, you can call TeleportService:ReserveServerAsync(PlaceId) and it will return the key as a string and the private server id as a number, you can then save the returned key somewhere and re-use it for TeleportService:TeleportToPrivateServer() to teleport players to the same server.

As an example:

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

local TargetPlaceId = 0 -- Replace with your target place ID
local GlobalKey = TeleportService:ReserveServerAsync(TargetPlaceId)

local function TeleportPlayer(Player : Player)
	TeleportService:TeleportToPrivateServer(TargetPlaceId, GlobalKey, {Player})
end

Players.PlayerAdded:Connect(TeleportPlayer)

This will teleport every player to the same reserved server, alternatively you could also save the key in a module script or in a storage container, up to you

1 Like

I should’ve probably specified that in your other post but yeah as long as the Key is the same, players will be teleported to the same reserved server and the Key won’t expire as long as it stays inside any scope (might even be valid forever, not sure)

Besides crossplay interference, you can just use the same ID and code. It’ll manage the server instance by itself. If your game allows console players to join inner servers without being in the initial teleport, an infrastructure decision has to be made if inner server duplication can exploit your game.

You can use memory stores. Use the reserved private server ID from the teleport result as a key with the value being the player private server owner’s ID. When the reserved server starts, it’ll use its own ID to check the memory store to know who owned the private server that created it.

The reserved server might try to check before the result is returned and the IDs are set by the lobby server. Maybe use something like -1 for a public lobby server’s “owner ID” key so inner reserved servers know to wait for the entry to exist. It’ll know it isn’t simply made from a public lobby because it’d be -1 instead of nil that’d it’d wait on.