How do I make lobby teleport system like doors has?

So, I need to make a lobby system like doors has. For example, I have the lobby place, where players use queue rooms. Now, the thing is, when I teleport them to the main game, how do I close the game so only those players who stood in that room teleport there? Because Im sure if I just teleprt those players they will end up with random players in the actual game. I dont know much in coding and I dont even know if I structured this question correct, but I hope you can help me I guess?

Basically how do I make lobby system like doors has, with server lock, the easiest way to do it

3 Likes

You could basically get all the players in the elevator / teleported whtever and you could then use TeleportService:ReserveServer() to get a code. Then use TeleportServer:TeleportToPrivateServerAsync() (doesn’t actually teleport the players to a private server it’s just a server that can only be joining if you have the same code).

If you’re confused, here’s a code snippet:

-- Countdown is finished and you need to tp those players
-- Idk but you need to get the players in the teleporter
local Code = TeleportService:ReserveServer(placeid)
TeleportService:TeleportToPrivateServerAsync(placeid, code, tableofplayerstotp)

I might be out walking or smthn because I haven’t for a while so I might not be here to respond that fast

4 Likes

Uh, there are diffrenent queues, for example 1 player or 4 or 2 or 3, what I wanted is one place with the maximum limit of 4 people that would lock itself after those players joined, is that possible?

Yeah you prob could, just check if the amount of Players in the table is not over four (btw they have to be PLAYERS not player names).

You could prob do like so:

local nameofplayerstable = {Player1, Player2, Player3, Player4}
-- THE ABOVE IS AN EXAMPLE
if #nameofplayerstable <= 4 then
-- Teleport them
end
3 Likes

so will this work like I want it to?

--code above
local function teleportPlayers()
	if #list > 0 then
		billboard.Frame.Status.Text = "TELEPORTING"
		billboard.Frame.Status.TextColor3 = Color3.fromRGB(255, 0, 0)
		local playersToTeleport = {}
		local teleportTime = 0
		for i=1,#list do
			if game.Players:findFirstChild(list[i]) then
				table.insert(playersToTeleport,game.Players:findFirstChild(list[i]))
				TransitionEvent:FireClient(game.Players:findFirstChild(list[i]))
			else
				table.remove(list,i)	
			end
		end 
		local code = TS:ReserveServer(placeId)
		teleporting = true
		TS:TeleportToPrivateServer(placeId,code,playersToTeleport)
		repeat wait() until #list <= 0
		billboard.Frame.Status.Text = "READY"
		billboard.Frame.Status.TextColor3 = Color3.fromRGB(255, 0, 0)
		teleporting = false
	end
end
-- code below
3 Likes