How would I use teleportservice to teleport players to a server which then no longer allows any new players?

I am trying to make a game that has consecutive rounds which players have to queue up for to be able to join them. However I want to make it so a game in-progress cannot be joined, and only new servers can be created when players are warped.

Currently I am using ReserveServer and TeleportToPrivateServer, but it still allows people to join the same server the next time the script is called. I instead want a new server to be made. How would I do this?

can we see the script? If your using reserve server correctly then it should work…

1 Like

Ah, I may not be using it correctly then in that case, here’s the script

local ts = game:GetService("TeleportService")
local reserve = ts:ReserveServer(6785266641)
local rs = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local playerTable = {}
local sss = game:GetService("ServerScriptService")
local be = sss:WaitForChild("Changed1")

be.Event:Connect(function()
	rs:FindFirstChild("Game1Waiting").Value = true
	local plrIndex = 0
	for i,plr in pairs(players:GetChildren()) do
		local inGame1 = plr:FindFirstChild("InGame1")
		if inGame1.Value == true then
			inGame1.Value = false
			local game1Players = rs:FindFirstChild("Game1Players")
			game1Players.Value = 0
			plrIndex += 1
			playerTable[plrIndex] = plr
			game.Workspace:FindFirstChild(plr.Name):Destroy()
		end
	end
	ts:TeleportToPrivateServer(6785266641, reserve, playerTable)
	print("players tped")
	wait(10)
	rs:FindFirstChild("Game1Waiting").Value = false
	print("game1 no longer waiting")
end)

Your issue is that your reserving the server at the beginning, you need to reserve one for every game that you make.

1 Like

So if I instead put the ReserveServer line inside the function it should work?

you are not creating a unique privateserver id for each wave of players
move local reserve = ts:ReserveServer(6785266641) to inside the event (also i recommend clearing playerTable everytime the event is called, i don’t know if it affects the script that much though)

1 Like
local ts = game:GetService("TeleportService")
local rs = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local playerTable = {}
local sss = game:GetService("ServerScriptService")
local be = sss:WaitForChild("Changed1")

be.Event:Connect(function()
	rs:FindFirstChild("Game1Waiting").Value = true
	local plrIndex = 0
	for i,plr in pairs(players:GetChildren()) do
		local inGame1 = plr:FindFirstChild("InGame1")
		if inGame1.Value == true then
			inGame1.Value = false
			local game1Players = rs:FindFirstChild("Game1Players")
			game1Players.Value = 0
			plrIndex += 1
			playerTable[plrIndex] = plr
			game.Workspace:FindFirstChild(plr.Name):Destroy()
		end
	end
	local reserve = ts:ReserveServer(6785266641)
	ts:TeleportToPrivateServer(6785266641, reserve, playerTable)
	print("players tped")
	wait(10)
	rs:FindFirstChild("Game1Waiting").Value = false
	print("game1 no longer waiting")
end)

that should work

3 Likes

Amazing, that worked perfectly, thank you very much

Thank you, good idea I will do that as well

1 Like