You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I need to teleport player to a private place.
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
local teleportEvent = game.ReplicatedStorage:WaitForChild("TeleportEvent")
local teleportService = game:GetService("TeleportService")
local PLACE_ID = 12553308618
local code = teleportService:ReserveServer(PLACE_ID)
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ReservedServerAccessCode = code
teleportOptions.ShouldReserveServer = true
local deb = false
local function acceptSignal(player)
if not deb then
deb = true
teleportService:TeleportAsync(PLACE_ID, {player}, teleportOptions)
wait(10)
deb = false
end
end
teleportEvent.OnServerEvent:Connect(acceptSignal)
My problem was that I was trying to teleport the player to a completely different place.
First of all, I created a new place in “Asset Manager”.
Then I published the place that I need for teleportation to the newly created one. I also had to change my script a bit.
local teleportEvent = game.ReplicatedStorage:WaitForChild("TeleportEvent")
local teleportService = game:GetService("TeleportService")
local PLACE_ID = 12695897147
local code = teleportService:ReserveServer(PLACE_ID)
local deb = false
local function acceptSignal(player)
if not deb then
deb = true
teleportService:TeleportToPrivateServer(PLACE_ID, code, {player})
wait(10)
deb = false
end
end
teleportEvent.OnServerEvent:Connect(acceptSignal)
Before that, I used the TeleportAsync() method. And in the rewritten script: TeleportToPrivateServer().