Cant make a reserved server

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)
2 Likes

My errors are, HTTP 403 forbidden (in studio) and HTTP 400 bad request in-game

Is the API enabled?


1 Like

I recommend using TeleportAsync instead.
TeleportService | Documentation - Roblox Creator Hub

Also, you should try again now. It might have been a Roblox outage.

2 Likes

I did, and I had no change at all. Just tried it again and still had the same issue.

Yes API was enabled, I enabled everything

I think that in order to reserve a server, the player has to be inside of the place’s universe. Is that the case in your script? Also, you can’t teleport in roblox studio.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.