Aprender
Clase de motor
TeleportService
No creable
Servicio

*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.


Resumen
Propiedades
Métodos
GetTeleportSetting(setting: string):Variant
ReserveServer(placeId: number):Tuple
Obsoleto
SetTeleportSetting(setting: string,value: Variant):()
Teleport(placeId: number,player: Instance,teleportData: Variant,customLoadingScreen: Instance):()
TeleportAsync(placeId: number,players: Instances,teleportOptions: Instance):Instance
TeleportPartyAsync(placeId: number,players: Instances,teleportData: Variant,customLoadingScreen: Instance):string
TeleportToPlaceInstance(placeId: number,instanceId: string,player: Instance,spawnName: string,teleportData: Variant,customLoadingScreen: Instance):()
TeleportToPrivateServer(placeId: number,reservedServerAccessCode: string,players: Instances,spawnName: string,teleportData: Variant,customLoadingScreen: Instance):()
TeleportToSpawnByName(placeId: number,spawnName: string,player: Instance,teleportData: Variant,customLoadingScreen: Instance):()
Eventos
TeleportInitFailed(player: Instance,teleportResult: Enum.TeleportResult,errorMessage: string,placeId: number,teleportOptions: Instance):RBXScriptSignal
Miembros heredados

Referencia API
Propiedades
CustomizedTeleportUI
Obsoleto

Métodos
GetArrivingTeleportGui
Capacidades: UI, Teleport
TeleportService:GetArrivingTeleportGui():Instance
Devuelve
Muestras de código
Manejo de una GUI de Carga de Teleportación
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local customLoadingScreen = TeleportService:GetArrivingTeleportGui()
if customLoadingScreen then
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
ReplicatedFirst:RemoveDefaultLoadingScreen()
customLoadingScreen.Parent = playerGui
task.wait(5)
customLoadingScreen:Destroy()
end

GetLocalPlayerTeleportData
Capacidades: Teleport
TeleportService:GetLocalPlayerTeleportData():Variant
Devuelve
Variant
Muestras de código
Obtener datos de teletransportación del jugador local
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("El jugador local llegó con estos datos:", teleportData)

GetPlayerPlaceInstanceAsync
Proporciona
Capacidades: Teleport
TeleportService:GetPlayerPlaceInstanceAsync(userId:User):Tuple
Parámetros
userId:User
Devuelve
Muestras de código
Siguiendo a Otro Jugador
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local followId = player.FollowUserId
if followId and followId ~= 0 then
-- ¿Está este jugador siguiendo a alguien? Si es así, encuentra dónde están
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId es el ID de usuario del jugador del que quieres recuperar el lugar y el ID de trabajo
if success then
-- Teleporta al jugador con éxito en función del jobId
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- Envía una advertencia basada en el error devuelto
warn(jobIdOrErr)
end
else
warn(("¡El jugador %d no está siguiendo a otro jugador!"):format(player.UserId))
end
end)

GetTeleportSetting
Capacidades: Teleport
TeleportService:GetTeleportSetting(setting:string):Variant
Parámetros
setting:string
Devuelve
Variant

PromptExperienceDetailsAsync
Proporciona
Capacidades: Teleport
TeleportService:PromptExperienceDetailsAsync(
player:Player, universeId:number
Parámetros
player:Player
universeId:number
Muestras de código
Mostrar Detalles de la Experiencia al Jugador
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local success, result = pcall(function()
TeleportService:PromptExperienceDetailsAsync(player, 8357232245)
end)
if not success then
warn("Error al mostrar los detalles de la experiencia: " .. tostring(result))
end
if result == Enum.PromptExperienceDetailsResult.PromptClosed then
print("El jugador cerró el aviso de detalles de la experiencia")
elseif result == Enum.PromptExperienceDetailsResult.TeleportAttempted then
print("El jugador eligió teletransportarse a la experiencia")
end

ReserveServer
Obsoleto

ReserveServerAsync
Proporciona
Capacidades: Teleport
TeleportService:ReserveServerAsync(placeId:number):Tuple
Parámetros
placeId:number
Devuelve
Muestras de código
ServicioDeTeletransporte: Teletransportar a un servidor reservado
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local code = TeleportService:ReserveServerAsync(game.PlaceId)
local players = Players:GetPlayers()
TeleportService:TeleportToPrivateServer(game.PlaceId, code, players)
-- Podrías añadir argumentos adicionales a esta función: spawnName, teleportData y customLoadingScreen
ServicioDeTeleportación: Teletransportarse a un Servidor Reservado a través del Chat
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Obtener el código guardado
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- Ninguno guardado, crear uno
code = TeleportService:ReserveServerAsync(game.PlaceId)
dataStore:SetAsync("ReservedServer", code)
end
local function joined(player)
player.Chatted:Connect(function(message)
if message == "reservado" then
TeleportService:TeleportToPrivateServer(game.PlaceId, code, { player })
end
end)
end
Players.PlayerAdded:Connect(joined)

SetTeleportGui
Capacidades: UI, Teleport
TeleportService:SetTeleportGui(gui:Instance):()
Parámetros
Devuelve
()
Muestras de código
Teletransportando al jugador local
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
local PLACE_ID = 0 -- reemplazar aquí
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- parentar la GUI de carga para este lugar
loadingGui.Parent = playerGui
-- establecer la GUI de carga para el lugar de destino
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)

SetTeleportSetting
Capacidades: Teleport
TeleportService:SetTeleportSetting(
setting:string, value:Variant
):()
Parámetros
setting:string
value:Variant
Devuelve
()

Teleport
Capacidades: UI, Teleport
TeleportService:Teleport(
placeId:number, player:Instance, teleportData:Variant, customLoadingScreen:Instance
):()
Parámetros
placeId:number
player:Instance
Valor predeterminado: "nil"
teleportData:Variant
customLoadingScreen:Instance
Valor predeterminado: "nil"
Devuelve
()
Muestras de código
Teletransportando al jugador local
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
local PLACE_ID = 0 -- reemplazar aquí
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- parentar la GUI de carga para este lugar
loadingGui.Parent = playerGui
-- establecer la GUI de carga para el lugar de destino
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)
Teletransportando desde el servidor
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 0 -- reemplaza aquí
local USER_ID = 1 -- reemplaza con el UserId del jugador
local player = Players:GetPlayerByUserId(USER_ID)
TeleportService:Teleport(PLACE_ID, player)

TeleportAsync
Proporciona
Capacidades: UI, Teleport
TeleportService:TeleportAsync(
placeId:number, players:Instances, teleportOptions:Instance
Parámetros
placeId:number
players:Instances
teleportOptions:Instance
Valor predeterminado: "nil"
Devuelve

TeleportPartyAsync
Proporciona
Capacidades: UI, Teleport
TeleportService:TeleportPartyAsync(
placeId:number, players:Instances, teleportData:Variant, customLoadingScreen:Instance
Parámetros
placeId:number
players:Instances
teleportData:Variant
customLoadingScreen:Instance
Valor predeterminado: "nil"
Devuelve
Muestras de código
Teletransportar a todos los jugadores en el servidor
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 0 -- reemplazar
local playerList = Players:GetPlayers()
local success, result = pcall(function()
return TeleportService:TeleportPartyAsync(PLACE_ID, playerList)
end)
if success then
local jobId = result
print("Jugadores teletransportados a", jobId)
else
warn(result)
end

TeleportToPlaceInstance
Capacidades: UI, Teleport
TeleportService:TeleportToPlaceInstance(
placeId:number, instanceId:string, player:Instance, spawnName:string, teleportData:Variant, customLoadingScreen:Instance
):()
Parámetros
placeId:number
instanceId:string
player:Instance
Valor predeterminado: "nil"
spawnName:string
teleportData:Variant
customLoadingScreen:Instance
Valor predeterminado: "nil"
Devuelve
()
Muestras de código
Siguiendo a Otro Jugador
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local followId = player.FollowUserId
if followId and followId ~= 0 then
-- ¿Está este jugador siguiendo a alguien? Si es así, encuentra dónde están
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId es el ID de usuario del jugador del que quieres recuperar el lugar y el ID de trabajo
if success then
-- Teleporta al jugador con éxito en función del jobId
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- Envía una advertencia basada en el error devuelto
warn(jobIdOrErr)
end
else
warn(("¡El jugador %d no está siguiendo a otro jugador!"):format(player.UserId))
end
end)

TeleportToPrivateServer
Capacidades: UI, Teleport
TeleportService:TeleportToPrivateServer(
placeId:number, reservedServerAccessCode:string, players:Instances, spawnName:string, teleportData:Variant, customLoadingScreen:Instance
):()
Parámetros
placeId:number
reservedServerAccessCode:string
players:Instances
spawnName:string
teleportData:Variant
customLoadingScreen:Instance
Valor predeterminado: "nil"
Devuelve
()
Muestras de código
ServicioDeTeleportación: Teletransportarse a un Servidor Reservado a través del Chat
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Obtener el código guardado
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- Ninguno guardado, crear uno
code = TeleportService:ReserveServerAsync(game.PlaceId)
dataStore:SetAsync("ReservedServer", code)
end
local function joined(player)
player.Chatted:Connect(function(message)
if message == "reservado" then
TeleportService:TeleportToPrivateServer(game.PlaceId, code, { player })
end
end)
end
Players.PlayerAdded:Connect(joined)
ServicioDeTeletransporte: Teletransportar a un servidor reservado
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local code = TeleportService:ReserveServerAsync(game.PlaceId)
local players = Players:GetPlayers()
TeleportService:TeleportToPrivateServer(game.PlaceId, code, players)
-- Podrías añadir argumentos adicionales a esta función: spawnName, teleportData y customLoadingScreen

TeleportToSpawnByName
Capacidades: UI, Teleport
TeleportService:TeleportToSpawnByName(
placeId:number, spawnName:string, player:Instance, teleportData:Variant, customLoadingScreen:Instance
):()
Parámetros
placeId:number
spawnName:string
player:Instance
Valor predeterminado: "nil"
teleportData:Variant
customLoadingScreen:Instance
Valor predeterminado: "nil"
Devuelve
()
Muestras de código
ServicioDeTeleportación:TeleportToSpawnByName
local TeleportService = game:GetService("TeleportService")
TeleportService:TeleportToSpawnByName(1818, "TeleportSpawn")

Eventos
LocalPlayerArrivedFromTeleport
Capacidades: Teleport
TeleportService.LocalPlayerArrivedFromTeleport(
loadingGui:Instance, dataTable:Variant
Parámetros
loadingGui:Instance
dataTable:Variant

TeleportInitFailed
Capacidades: Teleport
TeleportService.TeleportInitFailed(
player:Instance, teleportResult:Enum.TeleportResult, errorMessage:string, placeId:number, teleportOptions:Instance
Parámetros
player:Instance
teleportResult:Enum.TeleportResult
errorMessage:string
placeId:number
teleportOptions:Instance

©2026 Roblox Corporation. Roblox, el logotipo de Roblox y "Powering Imagination" son algunas de nuestras marcas registradas y no registradas en los Estados Unidos y otros países.