Class · inherits Instance
TeleportOptions
Optional input arguments to the TeleportService.TeleportAsync
function.
About TeleportOptions
This class is an optional parameter to the
TeleportService.TeleportAsync function that allows developers to
provide arguments for the teleport call.
Certain arguments in this class are not compatible with each other and cause
an error when passed to TeleportService.TeleportAsync:
- ReservedServerAccessCode + ServerInstanceId
- ShouldReserveServer + ServerInstanceId
- ShouldReserveServer + ReservedServerAccessCode
For more information on how to teleport players between servers, see Teleporting Between Places.
Properties 3
ReservedServerAccessCode
: stringThe reserved server access code that indicates the reserved server that the teleport should be to.This property indicates the reserved server access code for the reserved server that the user(s) should be teleported to.
The access code is obtained either from
TeleportService.ReserveServerAsyncor fromTeleportAsyncResult.ReservedServerAccessCode.For more information on how to teleport players between servers, see Teleporting Between Places.
ServerInstanceId
: stringTheDataModel.JobIdof the server instance to teleport to.This property indicates the
DataModel.JobIdof the server instance the user(s) should be teleported to.For more information on how to teleport players between servers, see Teleporting Between Places.
ShouldReserveServer
: booleanA flag to indicate if a reserved server should be allocated and the players should then be teleported to this allocation.This property indicates whether the teleport call should create a new reserved server. When set to true, a reserved server will be created and the player(s) will be teleported to the new server.
If set to false, the player(s) will be teleported to the public server with the specified
TeleportOptions.ServerInstanceIdif provided. WhenTeleportOptions.ServerInstanceIdis blank or no matching server is found, a new public server will be created to teleport the player(s) to.For more information on how to teleport players between servers, see Teleporting Between Places.
Methods 2
GetTeleportData
() → VariantReturns the teleport data stored in theTeleportOptionsinstance byTeleportOptions.SetTeleportData.This function returns the teleport data stored in the
TeleportOptionsinstance byTeleportOptions.SetTeleportData.Once a player has teleported, teleport data can be retrieved using the
Player.GetJoinDataandTeleportService.GetLocalPlayerTeleportDatafunctions.For more information on how to teleport players between servers, see Teleporting Between Places.
SetTeleportData
(teleportData: Variant) → ()Setter function for data to be passed to the destination place.This is a setter function for data to be passed to the destination place. On the destination place, this data can be retrieved using
Player.GetJoinDataorTeleportService.GetLocalPlayerTeleportData.For example, the following snippet would send the
DataModel.PlaceIdandDataModel.JobIdin a dictionary passing the teleport data in aTeleportOptionsinstance usingTeleportOptions.SetTeleportData:-- Server local teleportOptions = Instance.new("TeleportOptions") local teleportData = { placeId = game.PlaceId, jobId = game.JobId } teleportOptions:SetTeleportData(teleportData) TeleportService:TeleportAsync(game.PlaceId, {player}, teleportOptions)This data could then be retrieved upon arrival using the GetLocalPlayerTeleportData() function as follows:
-- Client local TeleportService = game:GetService("TeleportService") local teleportData = TeleportService:GetLocalPlayerTeleportData() if teleportData then local placeId = teleportData.placeId local jobId = teleportData.JobId endIf no
teleportDatawas set in the teleportation function this GetLocalPlayerTeleportData() will returnnil.Allowed data types
Teleport data may only contain value types. It cannot contain
Instancesor other types that reference engine state, as these cannot safely cross the boundary between servers.Allowed:
- Primitives:
bool,number, andstring - Value types such as
Vector3,CFrame,Color3,UDim2,NumberSequence,ColorSequence,Enumitems, and similar - Tables and arrays (without mixed keys) containing only the allowed types above, nested up to a reasonable depth and size
Not allowed (these will be removed from the data before the teleport completes):
Instanceand instance referencesConnections,RBXScriptSignal, and functionsSharedTable- Types that reference engine or
DataModelstate, such asInputObject,RaycastParams, andRaycastResult
If teleport data contains a disallowed type, that value is removed and an error is written to the developer console. Convert instance references to plain values (for example, a numeric ID or a string path).
For more information on how to send and receive user data along with teleports, see, see Teleporting Between Places.
- Primitives:
TeleportOptions also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.