Hi, I am trying to make a match making type of system where players enter an elevator and go to a reserved server in a place. I cant seem to figure out the issue with the Reserved Server it doesn’t work with regularly teleporting without the reserved server in-game either.
Here’s the code:
local id = 13675558103
local Service = game:GetService("TeleportService")
local MaxPlayers = 1
local TimerDuration = 10
local tppart = script.Parent.TPpart.CFrame.Position
local players = {}
local function teleportPlayers()
script.Parent.GUI.SurfaceGui.TextLabel.Text = "Teleporting.."
local code = Service:ReserveServer(id)
Service:TeleportToPrivateServer(id,code,players)
wait(5)
for _, player in ipairs(players) do
player:LoadCharacter()
end
players = {}
script.Parent.Timer.SurfaceGui.TextLabel.Text = "10"
script.Parent.GUI.SurfaceGui.TextLabel.Text = #players .. "/" .. MaxPlayers
end
local function updateTimerText(timeLeft)
script.Parent.Timer.SurfaceGui.TextLabel.Text = timeLeft
end
script.Parent.LobbyPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and #players < MaxPlayers and not table.find(players, player) then
table.insert(players, player)
script.Parent.GUI.SurfaceGui.TextLabel.Text = #players .. "/" .. MaxPlayers
hit.Parent:SetPrimaryPartCFrame(CFrame.new(tppart))
if #players == MaxPlayers then
local timeLeft = TimerDuration
while timeLeft > 0 do
updateTimerText(timeLeft)
wait(1)
timeLeft = timeLeft - 1
end
teleportPlayers()
end
end
end)