Teleport Service
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ข้อมูลสรุป
คุณสมบัติ
วิธีการ
GetLocalPlayerTeleportData():Variant |
GetPlayerPlaceInstanceAsync(userId: User):Tuple |
GetTeleportSetting(setting: string):Variant |
PromptExperienceDetailsAsync(player: Player,universeId: number):Enum.PromptExperienceDetailsResult |
ReserveServer(placeId: number):Tuple |
ReserveServerAsync(placeId: number):Tuple |
SetTeleportGui(gui: Instance):() |
SetTeleportSetting(setting: string,value: Variant):() |
TeleportAsync(placeId: number,players: {Player},teleportOptions: Instance):Instance |
TeleportPartyAsync(placeId: number,players: Instances,teleportData: Variant,customLoadingScreen: Instance):string |
TeleportToPrivateServer(placeId: number,reservedServerAccessCode: string,players: Instances,spawnName: string,teleportData: Variant,customLoadingScreen: Instance):() |
TeleportToSpawnByName(placeId: number,spawnName: string,player: Instance,teleportData: Variant,customLoadingScreen: Instance):() |
เหตุการณ์
LocalPlayerArrivedFromTeleport(loadingGui: Instance,dataTable: Variant):RBXScriptSignal |
TeleportInitFailed(player: Instance,teleportResult: Enum.TeleportResult,errorMessage: string,placeId: number,teleportOptions: Instance):RBXScriptSignal |
เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
Customized Teleport UI
วิธีการ
Get Arriving Teleport Gui
ส่งค่ากลับ
ตัวอย่างโค้ด
การจัดการ GUI โหลดการโทร
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()
endGet Local Player Teleport Data
Teleport Service: Get Local Player Teleport Data():Variant
ส่งค่ากลับ
Variant
ตัวอย่างโค้ด
การรับข้อมูลการเทเลพอร์ตของ LocalPlayer
local TeleportService = game:GetService("TeleportService")
local teleportData = TeleportService:GetLocalPlayerTeleportData()
print("ผู้เล่นท้องถิ่นมาถึงพร้อมข้อมูลนี้:", teleportData)Get Player Place Instance Async
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
ติดตามผู้เล่นคนอื่น
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
-- ผู้เล่นคนนี้กำลังติดตามใครอยู่หรือไม่? ถ้าใช่ ให้หาว่าพวกเขาอยู่ที่ไหน
local success, currentInstance, error, placeId, jobIdOrErr = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
-- followId คือ ID ผู้ใช้ของผู้เล่นที่คุณต้องการดึงสถานที่และ ID งาน
if success then
-- เทเลพอร์ตผู้เล่นเมื่อสำเร็จตาม jobId
TeleportService:TeleportToPlaceInstance(placeId, jobIdOrErr, player)
else
-- แสดงคำเตือนตามข้อผิดพลาดที่ส่งกลับ
warn(jobIdOrErr)
end
else
warn(("ผู้เล่น %d ไม่ได้ติดตามผู้เล่นคนอื่น!"):format(player.UserId))
end
end)Get Teleport Setting
Prompt Experience Details Async
Teleport Service: Prompt Experience Details Async(
ส่งค่ากลับ
ตัวอย่างโค้ด
แสดงรายละเอียดประสบการณ์ให้ผู้เล่น
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("เกิดข้อผิดพลาดในการแสดงรายละเอียดประสบการณ์: " .. tostring(result))
end
if result == Enum.PromptExperienceDetailsResult.PromptClosed then
print("ผู้เล่นปิดกล่องโต้ตอบรายละเอียดประสบการณ์")
elseif result == Enum.PromptExperienceDetailsResult.TeleportAttempted then
print("ผู้เล่นเลือกที่จะเทเลพอร์ตไปยังประสบการณ์")
endReserve Server
Reserve Server Async
Set Teleport Gui
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การโทรไปยังผู้เล่นท้องถิ่น
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 -- เปลี่ยนที่นี่
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui")
-- ตั้ง GUI โหลดสำหรับสถานที่นี้
loadingGui.Parent = playerGui
-- ตั้ง GUI โหลดสำหรับสถานที่ปลายทาง
TeleportService:SetTeleportGui(loadingGui)
TeleportService:Teleport(PLACE_ID)Set Teleport Setting
Teleport
Teleport Async
Teleport Party Async
Teleport To Place Instance
Teleport To Private Server
Teleport To Spawn By Name
เหตุการณ์
Local Player Arrived From Teleport
Teleport Service. Local Player Arrived From Teleport(
พารามิเตอร์
dataTable:Variant |
Teleport Init Failed
Teleport Service. Teleport Init Failed(
player:Instance, teleport Result:Enum.TeleportResult, error Message:string, place Id:number, teleport Options:Instance
พารามิเตอร์