Impara
Classe motore
TeleportService
Non costruibile
Assistenza

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.


Sommario
Proprietà
Metodi
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):()
Eventi
TeleportInitFailed(player: Instance,teleportResult: Enum.TeleportResult,errorMessage: string,placeId: number,teleportOptions: Instance):RBXScriptSignal
Membri ereditati

Riferimento API
Proprietà
CustomizedTeleportUI
Obsoleto

Metodi
GetArrivingTeleportGui
Capacità: UI, Teleport
TeleportService:GetArrivingTeleportGui():Instance
Restituzioni
Campioni di codice
Gestione di un GUI di Caricamento Teletrasporto
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
Capacità: Teleport
TeleportService:GetLocalPlayerTeleportData():Variant
Restituzioni
Variant
Campioni di codice
Ottenere i dati di teletrasporto del LocalPlayer
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("Il giocatore locale è arrivato con questi dati:", teleportData)

GetPlayerPlaceInstanceAsync
Resa
Capacità: Teleport
TeleportService:GetPlayerPlaceInstanceAsync(userId:User):Tuple
Parametri
userId:User
Restituzioni
Campioni di codice
Seguire un altro giocatore
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
-- Questo giocatore sta seguendo qualcun altro? In tal caso, scopri dove si trova
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId è l'ID utente del giocatore per il quale si desidera recuperare il luogo e l'ID del lavoro
if success then
-- Teletrasporta il giocatore al successo in base a jobId
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- Invia un avviso in base all'errore restituito
warn(jobIdOrErr)
end
else
warn(("Il giocatore %d non sta seguendo un altro giocatore!"):format(player.UserId))
end
end)

GetTeleportSetting
Capacità: Teleport
TeleportService:GetTeleportSetting(setting:string):Variant
Parametri
setting:string
Restituzioni
Variant

PromptExperienceDetailsAsync
Resa
Capacità: Teleport
TeleportService:PromptExperienceDetailsAsync(
player:Player, universeId:number
Parametri
player:Player
universeId:number
Campioni di codice
Mostra i dettagli dell'esperienza al giocatore
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("Errore nel richiedere i dettagli dell'esperienza: " .. tostring(result))
end
if result == Enum.PromptExperienceDetailsResult.PromptClosed then
print("Il giocatore ha chiuso la richiesta dei dettagli dell'esperienza")
elseif result == Enum.PromptExperienceDetailsResult.TeleportAttempted then
print("Il giocatore ha scelto di teletrasportarsi all'esperienza")
end

ReserveServer
Obsoleto

ReserveServerAsync
Resa
Capacità: Teleport
TeleportService:ReserveServerAsync(placeId:number):Tuple
Parametri
placeId:number
Restituzioni
Campioni di codice
TeleportService: Teletrasferisci a un Server Riservato
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)
-- Puoi aggiungere argomenti extra a questa funzione: spawnName, teleportData e customLoadingScreen
TeleportService: Teletrasporta a un Server Riservato tramite Chat
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Ottieni il codice salvato
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- Nessuno salvato, creane uno
code = TeleportService:ReserveServerAsync(game.PlaceId)
dataStore:SetAsync("ReservedServer", code)
end
local function joined(player)
player.Chatted:Connect(function(message)
if message == "riservato" then
TeleportService:TeleportToPrivateServer(game.PlaceId, code, { player })
end
end)
end
Players.PlayerAdded:Connect(joined)

SetTeleportGui
Capacità: UI, Teleport
TeleportService:SetTeleportGui(gui:Instance):()
Parametri
Restituzioni
()
Campioni di codice
Teletrasporto del giocatore locale
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 -- sostituisci qui
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- imposta il gui di caricamento per questo luogo
loadingGui.Parent = playerGui
-- imposta il gui di caricamento per il luogo di destinazione
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)

SetTeleportSetting
Capacità: Teleport
TeleportService:SetTeleportSetting(
setting:string, value:Variant
):()
Parametri
setting:string
value:Variant
Restituzioni
()

Teleport
Capacità: UI, Teleport
TeleportService:Teleport(
placeId:number, player:Instance, teleportData:Variant, customLoadingScreen:Instance
):()
Parametri
placeId:number
player:Instance
Valore predefinito: "nil"
teleportData:Variant
customLoadingScreen:Instance
Valore predefinito: "nil"
Restituzioni
()
Campioni di codice
Teletrasporto del giocatore locale
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 -- sostituisci qui
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- imposta il gui di caricamento per questo luogo
loadingGui.Parent = playerGui
-- imposta il gui di caricamento per il luogo di destinazione
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)
Teletrasporto dal server
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 0 -- sostituisci qui
local USER_ID = 1 -- sostituisci con l'UserId del giocatore
local player = Players:GetPlayerByUserId(USER_ID)
TeleportService:Teleport(PLACE_ID, player)

TeleportAsync
Resa
Capacità: UI, Teleport
TeleportService:TeleportAsync(
placeId:number, players:Instances, teleportOptions:Instance
Parametri
placeId:number
players:Instances
teleportOptions:Instance
Valore predefinito: "nil"
Restituzioni

TeleportPartyAsync
Resa
Capacità: UI, Teleport
TeleportService:TeleportPartyAsync(
placeId:number, players:Instances, teleportData:Variant, customLoadingScreen:Instance
Parametri
placeId:number
players:Instances
teleportData:Variant
customLoadingScreen:Instance
Valore predefinito: "nil"
Restituzioni
Campioni di codice
Teletrasporta tutti i giocatori nel server
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 0 -- sostituire
local playerList = Players:GetPlayers()
local success, result = pcall(function()
return TeleportService:TeleportPartyAsync(PLACE_ID, playerList)
end)
if success then
local jobId = result
print("Giocatori teletrasportati a", jobId)
else
warn(result)
end

TeleportToPlaceInstance
Capacità: UI, Teleport
TeleportService:TeleportToPlaceInstance(
placeId:number, instanceId:string, player:Instance, spawnName:string, teleportData:Variant, customLoadingScreen:Instance
):()
Parametri
placeId:number
instanceId:string
player:Instance
Valore predefinito: "nil"
spawnName:string
teleportData:Variant
customLoadingScreen:Instance
Valore predefinito: "nil"
Restituzioni
()
Campioni di codice
Seguire un altro giocatore
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
-- Questo giocatore sta seguendo qualcun altro? In tal caso, scopri dove si trova
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId è l'ID utente del giocatore per il quale si desidera recuperare il luogo e l'ID del lavoro
if success then
-- Teletrasporta il giocatore al successo in base a jobId
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- Invia un avviso in base all'errore restituito
warn(jobIdOrErr)
end
else
warn(("Il giocatore %d non sta seguendo un altro giocatore!"):format(player.UserId))
end
end)

TeleportToPrivateServer
Capacità: UI, Teleport
TeleportService:TeleportToPrivateServer(
placeId:number, reservedServerAccessCode:string, players:Instances, spawnName:string, teleportData:Variant, customLoadingScreen:Instance
):()
Parametri
placeId:number
reservedServerAccessCode:string
players:Instances
spawnName:string
teleportData:Variant
customLoadingScreen:Instance
Valore predefinito: "nil"
Restituzioni
()
Campioni di codice
TeleportService: Teletrasporta a un Server Riservato tramite Chat
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetGlobalDataStore()
-- Ottieni il codice salvato
local code = dataStore:GetAsync("ReservedServer")
if typeof(code) ~= "string" then -- Nessuno salvato, creane uno
code = TeleportService:ReserveServerAsync(game.PlaceId)
dataStore:SetAsync("ReservedServer", code)
end
local function joined(player)
player.Chatted:Connect(function(message)
if message == "riservato" then
TeleportService:TeleportToPrivateServer(game.PlaceId, code, { player })
end
end)
end
Players.PlayerAdded:Connect(joined)
TeleportService: Teletrasferisci a un Server Riservato
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)
-- Puoi aggiungere argomenti extra a questa funzione: spawnName, teleportData e customLoadingScreen

TeleportToSpawnByName
Capacità: UI, Teleport
TeleportService:TeleportToSpawnByName(
placeId:number, spawnName:string, player:Instance, teleportData:Variant, customLoadingScreen:Instance
):()
Parametri
placeId:number
spawnName:string
player:Instance
Valore predefinito: "nil"
teleportData:Variant
customLoadingScreen:Instance
Valore predefinito: "nil"
Restituzioni
()
Campioni di codice
TeleportService:TeleportToSpawnByName
local TeleportService = game:GetService("TeleportService")
TeleportService:TeleportToSpawnByName(1818, "TeleportSpawn")

Eventi
LocalPlayerArrivedFromTeleport
Capacità: Teleport
TeleportService.LocalPlayerArrivedFromTeleport(
loadingGui:Instance, dataTable:Variant
Parametri
loadingGui:Instance
dataTable:Variant

TeleportInitFailed
Capacità: Teleport
TeleportService.TeleportInitFailed(
player:Instance, teleportResult:Enum.TeleportResult, errorMessage:string, placeId:number, teleportOptions:Instance
Parametri
player:Instance
teleportResult:Enum.TeleportResult
errorMessage:string
placeId:number
teleportOptions:Instance

© 2026 Roblox Corporation. Roblox, il logo Roblox e Powering Imagination sono tra i nostri marchi registrati e non registrati negli Stati Uniti. e altri paesi.