How do I "lock" servers like Rooms does?

I’m making a Rooms inspired game, and I want to make servers “lock” like in the game Rooms. From what I can remember, this makes so after a certain action (in this case, starting the run) will kick any players that join the server. But it also makes it so players that simply try to join the game rather than join the server directly will be put in a new server or a server that has not started the run yet. I know how to kick players, but I want to make it so they won’t join any servers that started the game so I can make playing the game more convenient for them.

I’ve tried looking for tutorials, and posts on the devforum, but in the moderate searching I’ve done, I haven’t found any way to do this specifically.

I have little experience with this kind of thing specifically, so I have no idea where to start and how to pull this off. Hopefully I remember the details correctly, so is it possible and how do I pull it off?

1 Like

I am pretty sure TeleportService:ReserveServer creates a server that can only be accessed with a unique access code. There would be no need to kick anyone, people will be unable to join it and anyone trying to would be redirected to another server.

On top of this joining non-root places will by default redirect you to the root place (e.g. a lobby).

2 Likes

This is just reserved servers. You can create a reserved server code with TeleportService.ReserveServer, then teleport a group of players using TeleportAsync or TeleportToPrivateServer.

local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 123456789

local function newGame(players: {Player})
  local code, serverid = TeleportService:ReserveServer(PLACE_ID)
  TeleportService:TeleportToPrivateServer(PLACE_ID, code, players)
end
1 Like

No, it doesn’t teleport you at all

To answer OP: i think its the same as how you don’t join a server that kicks everyone on join to shut it down when you press play

Could you clarify what you mean by that?

It’s the “how you don’t join a server that kicks everyone on join to shut it down when you press play” that confuses me and I want more details that could lead to a solution. It might just be the wording, though.

Clarify or dont spread misinformation.


To OP
The first 2 replies should be the solution you’re asking for.

And you can use Memory service to communicate between servers to let them know that you locked server X and your code should hide it from the player and not teleport any more players to it.

There are a few ways you can do this.

  1. Kicking the players directly. If a player joins and the run is started then kick them immediately.

  2. Teleporting the player everytime they join. If a player joins then search for a server where the run hasn’t started yet and teleport them to it. Do ensure that the servers are created using TeleportService:ReserverServer. You can use TeleportService:TeleportAsync to teleport the players.

The Rooms lobby doesn’t teleport you. I’ve played the game before and its just a normal 4 player server people can join and then just stops allowing joins once the first door opens

1 Like

I have a friend who is obsessed with Rooms games, so I can confirm this

IIRC it just kicks you. However, OP should not do that and instead make a main menu / lobby Place that then reserves a server and sends a group of players into the game Place. A la Doors/Pressure/Dead Rails/any game that needs to “lock servers” lobby.

1 Like

Alright, I’ll go with this then, since I can’t figure out how to easily do what Rooms did where players that try to join simply go elsewhere. I’d try to spend a lot more time on it, but I challenged myself to make this game in a week. Once that’s done, though, I’ll try to experiment using info from the other replies here

I do think that a lobby system will partially mess up the immersion of my game, so I’ll make a cutscene when you open the first door and teleport the players then.
It’s not exactly what I want, but thank you all for replying nonetheless.

1 Like

You could have everyone in the same server, but each person has their own little “instance” of the game that they can invite other people to. Might be more complicated than the lobby, but it could help with your immersion since there’s no usage of TeleportService. IIRC you can also add your own loading screen to teleports as well.