Aprenda
Classe do mecanismo
TeleportService
Não criável
Serviço

*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.


Resumo
Propriedades
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
Membros herdados

Referência API
Propriedades
CustomizedTeleportUI
Obsoleto

Métodos
GetArrivingTeleportGui
Recursos: UI, Teleport
TeleportService:GetArrivingTeleportGui():Instance
Devolução
Amostras de código
Gerenciando uma GUI de Carregamento de Teleporte
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
Recursos: Teleport
TeleportService:GetLocalPlayerTeleportData():Variant
Devolução
Variant
Amostras de código
Obtendo Dados de Teletransporte do LocalPlayer
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("O jogador local chegou com estes dados:", teleportData)

GetPlayerPlaceInstanceAsync
Rendimentos
Recursos: Teleport
TeleportService:GetPlayerPlaceInstanceAsync(userId:User):Tuple
Parâmetros
userId:User
Devolução
Amostras de código
Seguindo Outro Jogador
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
-- Este jogador está seguindo alguém? Se sim, descubra onde ele está
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId é o ID do usuário do jogador cujo lugar e ID do trabalho você deseja recuperar
if success then
-- Teleporta o jogador com base no jobId em caso de sucesso
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- Emite um aviso com base no erro retornado
warn(jobIdOrErr)
end
else
warn(("O jogador %d não está seguindo outro jogador!"):format(player.UserId))
end
end)

GetTeleportSetting
Recursos: Teleport
TeleportService:GetTeleportSetting(setting:string):Variant
Parâmetros
setting:string
Devolução
Variant

PromptExperienceDetailsAsync
Rendimentos
Recursos: Teleport
TeleportService:PromptExperienceDetailsAsync(
player:Player, universeId:number
Parâmetros
player:Player
universeId:number
Amostras de código
Mostrar Detalhes da Experiência ao Jogador
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("Erro ao solicitar detalhes da experiência: " .. tostring(result))
end
if result == Enum.PromptExperienceDetailsResult.PromptClosed then
print("O jogador fechou o prompt de detalhes da experiência")
elseif result == Enum.PromptExperienceDetailsResult.TeleportAttempted then
print("O jogador escolheu teletransportar-se para a experiência")
end

ReserveServer
Obsoleto

ReserveServerAsync
Rendimentos
Recursos: Teleport
TeleportService:ReserveServerAsync(placeId:number):Tuple
Parâmetros
placeId:number
Devolução
Amostras de código
TeleportService: Teleportar para um 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)
-- Você pode adicionar argumentos extras a esta função: spawnName, teleportData e customLoadingScreen
TeleportService: Teleportar para um Servidor Reservado via Chat
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Obter o código salvo
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- Nenhum salvo, crie um
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
Recursos: UI, Teleport
TeleportService:SetTeleportGui(gui:Instance):()
Parâmetros
Devolução
()
Amostras de código
Teleportando o jogador 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 -- substitua aqui
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- parent the loading gui for this place
loadingGui.Parent = playerGui
-- set the loading gui for the destination place
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)

SetTeleportSetting
Recursos: Teleport
TeleportService:SetTeleportSetting(
setting:string, value:Variant
):()
Parâmetros
setting:string
value:Variant
Devolução
()

Teleport
Recursos: UI, Teleport
TeleportService:Teleport(
placeId:number, player:Instance, teleportData:Variant, customLoadingScreen:Instance
):()
Parâmetros
placeId:number
player:Instance
Valor Padrão: "nil"
teleportData:Variant
customLoadingScreen:Instance
Valor Padrão: "nil"
Devolução
()
Amostras de código
Teleportando o jogador 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 -- substitua aqui
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- parent the loading gui for this place
loadingGui.Parent = playerGui
-- set the loading gui for the destination place
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)
Teleportando do servidor
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 0 -- substitua aqui
local USER_ID = 1 -- substitua pelo UserId do jogador
local player = Players:GetPlayerByUserId(USER_ID)
TeleportService:Teleport(PLACE_ID, player)

TeleportAsync
Rendimentos
Recursos: UI, Teleport
TeleportService:TeleportAsync(
placeId:number, players:Instances, teleportOptions:Instance
Parâmetros
placeId:number
players:Instances
teleportOptions:Instance
Valor Padrão: "nil"
Devolução

TeleportPartyAsync
Rendimentos
Recursos: UI, Teleport
TeleportService:TeleportPartyAsync(
placeId:number, players:Instances, teleportData:Variant, customLoadingScreen:Instance
Parâmetros
placeId:number
players:Instances
teleportData:Variant
customLoadingScreen:Instance
Valor Padrão: "nil"
Devolução
Amostras de código
Teletransporte todos os jogadores no servidor
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 0 -- substitua
local playerList = Players:GetPlayers()
local success, result = pcall(function()
return TeleportService:TeleportPartyAsync(PLACE_ID, playerList)
end)
if success then
local jobId = result
print("Jogadores teletransportados para", jobId)
else
warn(result)
end

TeleportToPlaceInstance
Recursos: 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 Padrão: "nil"
spawnName:string
teleportData:Variant
customLoadingScreen:Instance
Valor Padrão: "nil"
Devolução
()
Amostras de código
Seguindo Outro Jogador
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
-- Este jogador está seguindo alguém? Se sim, descubra onde ele está
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId é o ID do usuário do jogador cujo lugar e ID do trabalho você deseja recuperar
if success then
-- Teleporta o jogador com base no jobId em caso de sucesso
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- Emite um aviso com base no erro retornado
warn(jobIdOrErr)
end
else
warn(("O jogador %d não está seguindo outro jogador!"):format(player.UserId))
end
end)

TeleportToPrivateServer
Recursos: 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 Padrão: "nil"
Devolução
()
Amostras de código
TeleportService: Teleportar para um Servidor Reservado via Chat
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Obter o código salvo
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- Nenhum salvo, crie um
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)
TeleportService: Teleportar para um 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)
-- Você pode adicionar argumentos extras a esta função: spawnName, teleportData e customLoadingScreen

TeleportToSpawnByName
Recursos: UI, Teleport
TeleportService:TeleportToSpawnByName(
placeId:number, spawnName:string, player:Instance, teleportData:Variant, customLoadingScreen:Instance
):()
Parâmetros
placeId:number
spawnName:string
player:Instance
Valor Padrão: "nil"
teleportData:Variant
customLoadingScreen:Instance
Valor Padrão: "nil"
Devolução
()
Amostras de código
TeleportService:TeleportToSpawnByName
local TeleportService = game:GetService("TeleportService")
TeleportService:TeleportToSpawnByName(1818, "TeleportSpawn")

Eventos
LocalPlayerArrivedFromTeleport
Recursos: Teleport
TeleportService.LocalPlayerArrivedFromTeleport(
loadingGui:Instance, dataTable:Variant
Parâmetros
loadingGui:Instance
dataTable:Variant

TeleportInitFailed
Recursos: 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, o logotipo Roblox e Powering Imagination estão entre nossas marcas registradas e não registradas nos EUA e em outros países.