Properties
string
|
The reserved server access code that indicates the reserved server that the teleport should be to |
string
|
The |
bool
|
A flag to indicate if a reserved server should be allocated and the players should then be teleported to this allocation |
bool
|
Determines if an |
string
[ReadOnly]
[NotReplicated]
|
A read-only string representing the class this |
int
[Hidden]
[ReadOnly]
[NotReplicated]
[Deprecated]
|
The cost of saving the instance using data persistence. |
string
|
A non-unique identifier of the |
Instance
[NotReplicated]
|
Determines the hierarchical parent of the |
bool
[Hidden]
|
A deprecated property that used to protect |
int64
[Hidden]
[NotReplicated]
|
bool
[Hidden]
[NotReplicated]
[Deprecated]
|
string
[ReadOnly]
[NotReplicated]
[Deprecated]
|
Functions
Variant
|
Returns the teleport data stored in the |
void
|
Setter function for data to be passed to the destination place |
void
|
This function destroys all of an |
Instance
|
Create a copy of an object and all its descendants, ignoring objects that are not |
void
|
Sets the |
Instance
|
Returns the first ancestor of the |
Instance
|
Returns the first ancestor of the |
Instance
|
Returns the first ancestor of the |
Instance
|
Returns the first child of the |
Instance
|
Returns the first child of the |
Instance
|
Returns the first child of the |
Instance
|
Returns the first descendant found with the given |
Actor
|
Returns the Actor associated with the Instance, usually the first Actor ancestor |
Variant
|
Returns the attribute which has been assigned to the given name |
RBXScriptSignal
|
Returns an event that fires when the given attribute changes |
Dictionary
|
Returns a dictionary of string → variant pairs for each of the |
Objects
|
Returns an array containing all of the |
string
[NotBrowsable]
|
Returns a coded string of the |
Array
[CustomLuaState]
|
Returns an array containing all of the descendants of the instance |
string
|
Returns a string describing the |
RBXScriptSignal
|
Get an event that fires when a given property of an object changes. |
bool
[CustomLuaState]
|
Returns true if an |
bool
|
Returns true if an |
bool
|
Returns true if an |
void
[Deprecated]
|
Sets the object’s Parent to nil, and does the same for all its descendants. |
void
|
Sets the attribute with the given name to the given value |
Instance
[CustomLuaState]
[CanYield]
|
Returns the child of the |
Objects
[Deprecated]
|
Returns an array of the object’s children. |
Instance
[Deprecated]
|
void
[Deprecated]
|
Instance
[Deprecated]
|
Objects
[Deprecated]
|
bool
[Deprecated]
[CustomLuaState]
|
bool
[Deprecated]
|
void
[Deprecated]
|
Events
RBXScriptSignal
|
Fires when the |
RBXScriptSignal
|
Fires whenever an attribute is changed on the |
RBXScriptSignal
|
Fired immediately after a property of an object changes. |
RBXScriptSignal
|
Fires after an object is parented to this |
RBXScriptSignal
|
Fires after a child is removed from this |
RBXScriptSignal
|
Fires after a descendant is added to the |
RBXScriptSignal
|
Fires immediately before a descendant of the |
RBXScriptSignal
|
Fires immediately before the instance is destroyed via |
RBXScriptSignal
[Deprecated]
|
Code Samples
Teleporting To a Reserved Server
The example below demonstrates how to use TeleportService/TeleportAsync
to teleport a player to a reserved server and then save the TeleportAsyncResult/ReservedServerAccessCode
to a datastore for later use to teleport other players to the same server. Saving off the access code is important because players cannot join reserved servers via the TeleportService
without the reserved server access code.
Developers must save the reserved access code via GlobalDataStore|DataStores
or some other location in order to keep it. For example, developers can create a DataStore for access codes and then save the reserved server access code as the value and the PrivateServerId as the key. By saving the access code to a datastore using the TeleportAsyncResult/PrivateServerId
as the key, developers can get the server access code from within the reserved server and send it to other servers using the MessagingService
.
For example, the MessagingService can be used as a part of an invitation system that allows players on a reserved server to invite players on different servers to their server. The reserved server access code can be sent using this service to be handled by a subscribed server containing the invited player. The invited player’s server can then handle the message and teleport the invited player using a TeleportAsync specifying the access code through the TeleportOptions/ReservedServerAccessCode
property of the TeleportOptions
.
local DataStoreService = game:GetService("DataStoreService") local TeleportService = game:GetService("TeleportService") local ServerAccessCodes = DataStoreService:GetDataStore("ReservedServerAccessCodes") -- Teleport the player to a reserved server local teleportOptions = Instance.new(“TeleportOptions”) teleportOptions.ShouldReserveServer = true local teleportResult = TeleportService:TeleportAsync(placeId, {player}, teleportOptions) -- Save the ReservedServerAccessCode from the TeleportResult instance ServerAccessCodes:SetAsync(teleportResult.PrivateServerId, teleportResult.ReservedServerAccessCode) -- To retrieve the access code (can only be done from in the reserved server) local accessCode = game.PrivateServerId ~= "" and ServerAccessCodes:GetAsync(game.PrivateServerId)