This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
This function returns an access code that can be used to teleport players to a reserved server, along with the
DataModel/PrivateServerId for it.
ReserveServer can only be called on the server.
The following are characteristics of reserved servers:
- They can only be accessed using
TeleportService/TeleportToPrivateServer, with the access code ReserveServer returns
- A game server is started when the access code is first used
- Access codes remain valid indefinitely, meaning reserved servers can still be joined if no game server is running (in this case a new game server will be started)
You can see if the current server is a reserved server by using the following code:
local isReserved = game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0
DataModel/PrivateServerId is constant across all server instances associated with the server access code, the
DataModel/JobId is not.
This service does not work during playtesting in Roblox Studio — To test aspects of your game using it, you must publish the game and play it in the Roblox application.
Players on Xbox One with cross-platform play disabled will arrive in a different server with players with cross-platform play enabled. This can cause multiple game servers with the same PrivateServerId to exist.
The server access code required by
TeleportService: Teleport to a Reserved Server via Chat
The following code would reserve one server, if it hasn’t be reserved before. Whenever someone says “reserved”, they will be teleported to the private server.
TeleportService: Teleport to a Reserved Server
The following code would send everyone in the current game to a reserved server. Since reserved servers can only be joined by using
/TeleportService/TeleportToPrivateServer, nobody will join the reserved server afterwards.
Mind that, since everyone will be teleported, the current server will (probably) shutdown as nobody would be left in it.