TeleportOptions
Optional input arguments to the TeleportService:TeleportAsync() function.
| Memory category | Instances |
|---|
Member index 7
Description
This class is an optional parameter to the TeleportService:TeleportAsync() function that allows developers to provide arguments for the teleport call.
Only one of the following private server routing fields may be set at a time. Setting more than one causes an error:
- TeleportOptions.ReservedServerId
- TeleportOptions.VipServerId
- TeleportOptions.ReservedServerAccessCode
- TeleportOptions.ShouldReserveServer
- TeleportOptions.ServerInstanceId
For more information on how to teleport players between servers, see Teleporting Between Places.
History 24
- 746 Change Tags of ShouldReserveServer from [] to [Deprecated]
- 746 Change PreferredDescriptor of ShouldReserveServer from to ReservedServerId
- 746 Change Tags of ReservedServerAccessCode from [] to [Deprecated]
- 746 Change PreferredDescriptor of ReservedServerAccessCode from to ReservedServerId
- 740 Add VipServerId
- 740 Add ReservedServerId
- 731 Change Default of ShouldReserveServer from to false
- 726 Change Default of ShouldReserveServer from false to
- 573 Change ReturnType of SetTeleportData from void to null
- 553 Change Default of ShouldReserveServer from to false
- 486 Change ThreadSafety of ShouldReserveServer from ReadOnly to ReadSafe
- 486 Change ThreadSafety of ServerInstanceId from ReadOnly to ReadSafe
- 486 Change ThreadSafety of ReservedServerAccessCode from ReadOnly to ReadSafe
- 462 Change ThreadSafety of SetTeleportData from to Unsafe
- 462 Change ThreadSafety of GetTeleportData from to Unsafe
- 462 Change ThreadSafety of ShouldReserveServer from to ReadOnly
- 462 Change ThreadSafety of ServerInstanceId from to ReadOnly
- 462 Change ThreadSafety of ReservedServerAccessCode from to ReadOnly
- 458 Add SetTeleportData
- 458 Add GetTeleportData
- 458 Add ShouldReserveServer
- 458 Add ServerInstanceId
- 458 Add ReservedServerAccessCode
- 458 Add TeleportOptions
Members 7
GetTeleportData
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Variant | ||
This function returns the teleport data stored in the TeleportOptions instance by TeleportOptions:SetTeleportData().
Once a player has teleported, teleport data can be retrieved using the Player:GetJoinData() and TeleportService:GetLocalPlayerTeleportData() functions.
For more information on how to teleport players between servers, see Teleporting Between Places.
| Thread safety | Unsafe |
|---|
History 2
- 462 Change ThreadSafety of GetTeleportData from to Unsafe
- 458 Add GetTeleportData
ReservedServerAccessCode
| Type | Default | |
|---|---|---|
| string | ||
This property is deprecated and no longer supported. It remains available for backward compatibility but should not be used for new work.
It 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:ReserveServerAsync() or from TeleportAsyncResult.ReservedServerAccessCode.
For new work, use TeleportOptions.ReservedServerId with a developer-generated GUID instead. See Teleporting Between Places.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | true |
History 5
- 746 Change Tags of ReservedServerAccessCode from [] to [Deprecated]
- 746 Change PreferredDescriptor of ReservedServerAccessCode from to ReservedServerId
- 486 Change ThreadSafety of ReservedServerAccessCode from ReadOnly to ReadSafe
- 462 Change ThreadSafety of ReservedServerAccessCode from to ReadOnly
- 458 Add ReservedServerAccessCode
ReservedServerId
| Type | Default | |
|---|---|---|
| string | ||
This property specifies a developer-supplied identifier for a reserved server. Set it to any random GUID to target a new, random reserved server. A random GUID can be generated with HttpService:GenerateGUID(false). Pass the TeleportOptions instance to TeleportService:TeleportAsync().
The first teleport using some new ID creates the reserved server. Reusing the same ID routes subsequent teleports to that same reserved server.
For more information on how to teleport players between servers, see Teleporting Between Places.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | true |
History 1
- 740 Add ReservedServerId
ServerInstanceId
| Type | Default | |
|---|---|---|
| string | ||
This property indicates the DataModel.JobId of the server instance the user(s) should be teleported to.
For more information on how to teleport players between servers, see Teleporting Between Places.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | true |
History 3
- 486 Change ThreadSafety of ServerInstanceId from ReadOnly to ReadSafe
- 462 Change ThreadSafety of ServerInstanceId from to ReadOnly
- 458 Add ServerInstanceId
SetTeleportData
| Parameters (1) | ||
|---|---|---|
| teleportData | Variant | |
| Returns (1) | ||
| null | ||
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:GetJoinData() or TeleportService:GetLocalPlayerTeleportData().
For example, the following snippet would send the DataModel.PlaceId and DataModel.JobId in a dictionary passing the teleport data in a TeleportOptions instance using TeleportOptions:SetTeleportData():
1 2 3 4 5 6 7 8 | |
This data could then be retrieved upon arrival using the GetLocalPlayerTeleportData() function as follows:
1 2 3 4 5 6 7 8 | |
If no teleportData was set in the teleportation function this
GetLocalPlayerTeleportData() will return nil.
Allowed data types
Teleport data may only contain value types. It cannot contain Instances or 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):
- Instance and instance references
- Connections, RBXScriptSignal, and functions
SharedTable- Types that reference engine or DataModel state, such as InputObject, RaycastParams, and RaycastResult
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.
| Thread safety | Unsafe |
|---|
History 3
- 573 Change ReturnType of SetTeleportData from void to null
- 462 Change ThreadSafety of SetTeleportData from to Unsafe
- 458 Add SetTeleportData
ShouldReserveServer
| Type | Default | |
|---|---|---|
| bool | false | |
When set to true, a reserved server is created and the player(s) are
teleported to the new server.
This property is deprecated and no longer supported. For new work, generate a GUID with HttpService:GenerateGUID(false), set TeleportOptions.ReservedServerId, and call TeleportService:TeleportAsync().
For more information on how to teleport players between servers, see Teleporting Between Places.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | true |
History 8
- 746 Change Tags of ShouldReserveServer from [] to [Deprecated]
- 746 Change PreferredDescriptor of ShouldReserveServer from to ReservedServerId
- 731 Change Default of ShouldReserveServer from to false
- 726 Change Default of ShouldReserveServer from false to
- 553 Change Default of ShouldReserveServer from to false
- 486 Change ThreadSafety of ShouldReserveServer from ReadOnly to ReadSafe
- 462 Change ThreadSafety of ShouldReserveServer from to ReadOnly
- 458 Add ShouldReserveServer
VipServerId
| Type | Default | |
|---|---|---|
| string | ||
This property specifies the identifier for a VIP server (known as private servers to players). Set it to the DataModel.PrivateServerId of the target VIP server and pass the TeleportOptions instance to TeleportService:TeleportAsync().
This property is distinct from TeleportOptions.ReservedServerId, which targets reserved servers.
A VIP server ID is scoped to the experience that owns the VIP server. You may use it with the place ID of any place in that experience, not just the root place, but using it with a place ID from a different experience is rejected.
When no private-server routing field is set, the engine chooses the destination server: the join can be public, or a VIP server the player has recent context for.
For more information on how to teleport players between servers, see Teleporting Between Places.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | true |
History 1
- 740 Add VipServerId