TeleportAsyncResult
TeleportAsyncResult : Instance
Overview
The result instance returned after TeleportService:TeleportAsync completes. When a teleport request is processed successfully, it carries information about the server the player joined and delivers it back to the caller.
Properties
ReservedServerAccessCode
string
The access code of the reserved server that the player joined through this teleport.
When a new private server was created by setting TeleportOptions.ShouldReserveServer to true, this value can later be passed to TeleportOptions.ReservedServerAccessCode to teleport other players into the same server.
If the player joined a public server rather than a reserved one, this may be an empty string.
Code Samples
local TeleportService = game:GetService("TeleportService")
local targetPlaceId = 1234 -- PlaceId of a Place connected to the current World
-- Create a reserved server
local success, errorOrAccessCode = pcall(function()
return TeleportService:ReserveServerAsync(targetPlaceId)
end)
if not success or errorOrAccessCode == nil or errorOrAccessCode == "" then
return
end
-- Configure TeleportOptions
local options = Instance.new("TeleportOptions")
options.ReservedServerAccessCode = errorOrAccessCode -- Reserved server access code
options.ShouldReserveServer = false -- Whether to create a new reserved server session (must be false when using ReservedServerAccessCode)
-- Execute teleport
local success, errorOrResult = pcall(function()
local players = { player } -- Players to teleport
local teleportResult = TeleportService:TeleportAsync(targetPlaceId, players, options)
return teleportResult
end)
print("TeleportAsyncResult.ReservedServerAccessCode : ", errorOrResult.ReservedServerAccessCode)Methods
Events
See also
Place & TeleportLast updated