How would I go on making a private game system?

Hi! This is my first post and I hope I’m doing everything right. Please correct me if I don’t! :smile:

  1. What do you want to achieve?
    I want to make a private game system where if a group of players wants to play in a private lobby/game, it would teleport them to a different world where only they can play until the game is over. A good example of this would be the game Tower Defense Simulator.

  2. What is the issue?
    The issue is that I don’t know how I would implement this into my game without any significant lag and be done efficiently.

  3. What solutions have you thought of so far?
    I have thought of adding a bunch of different worlds to my game and when the group of players wants to play I would teleport them to that game and send a signal back saying “this world is in use” and would block anyone else from joining until the game is over. What I don’t like about this method is that I don’t know if creating something like 20 worlds in one game would lag the server out.
    I was also thinking that someway a script can create a new world and delete it after the game is done but I don’t know if that would work.

Thanks for any help! :slight_smile:

Something like this could be done with zero code just by using the built-in “Private Server” feature. All the player has to do is purchase a private server from your game (they can be free), and they can join it with their friends and play however long they want to!

If you really want to make it all happen in-game and such, you’d probably need to be able to manipulate servers, teleporting players between them, and not allowing new players to join (probably through using a separate place that isn’t the main “click to play” place, which would stop players from automatically joining unless teleported).

1 Like

Hi! Thanks for the answer but its not exactly what I want. Sorry I if I did not clarify that much but I want something like Tower Defense Simulator where you go play with random players in a match. When you join a round it teleports you to a place called “Game” and it stays open until the round ends. I don’t really want to use Private Servers because you would need to be friends with that person.

I see what you mean now. Then yeah, a way I can think of making this happen is to implement a system like this:

I haven’t actually done any work with manipulating servers, but of course it can be done. If it doesn’t matter who they play with, then just teleporting them to another place might work.

Good idea, I’ll try to implement this. If it works I’ll mark yours as an answer :slight_smile:

I think what you are looking for is TeleportService | Roblox Creator Documentation
Here is an example.

local gameID = 0
local TeleportService = game:GetService("TeleportService")
local code = TeleportService:ReserveServer(gameID)