PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

ReserveServer

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.

Reserved Servers

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

The DataModel/PrivateServerId is constant across all server instances associated with the server access code, the DataModel/JobId is not.

Studio limitation

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.

Cross-Platform Play

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.

Parameters

Name Type Default Description

The DataModel/PlaceId of the place the reserved server is being created for

Returns

Return Type Summary

The server access code required by TeleportService/TeleportToPrivateServer and the DataModel/PrivateServerId for the reserved server


Code Samples


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.