How would I make a Custom Server/Lobby Creation system

Hello Developers,

So I was trying to find videos on how to make a system where players can create a server that is private or public or join a public one. So in more detail you can create a server with 3 options public, private, or friends only. Once you have created the server it teleports you there and you will have a server code and if players type in that code they can join your exact server even if its private. And you can change the server thing to public which makes it show up on the public server area, private, or friends only where it only shows up in the friends area to the clients friends.

I know this is very specific so if anyone could like send a video or post or something on how to do this or help me with anything that would be great thanks.

Thanks

6 Likes

I did a project like this last week, just to see if it was possible.
So you will need to randomly generate an access code and use the ReserveServer function of the TeleportService. Save both of them in a DataStore.

  1. Save it to the player that created the server ID as: ID-ReservedServerId
  2. Save it the access code as: AccessCode
  3. The status of the server (private, friends, public, etc.) as: AccessCode-ServerStatus

Creating the server saves those values in the DataStore. Then inputing the generated AccessCode, will load what has been previously saved. You then just need to teleport the player that inputed that number, to the server with the ReservedServerId.

When the player joins that server, make sure to reload the previously saved items, so you can give him his AccessCode, for him to be able to invite other players.

Then in that server add a Settings GUI, make sure it’s private by default.
You will automatically know that the first player that joins is the owner by making the script make him join his server as soon as it’s created. Then make sure to save the changes every time in the DataStore.

NOTES:
-While generating the access code, verify that the access code is not already in use, so it doesn’t cause problems.
-Make sure that after the created server shuts down, the codes are removed from the DataStore, using the RemoveAsync function, this will make sure the AccessCode can be used again.
-ReserveServer only works on server sided scripts.

17 Likes

Sorry I don’t know much about teleport service and all that but how would the game know to teleport a player to a specific reserved server by typing in the saved access code. Because other players will join the exact server with the code. An example of this is the creating private server in the game final stand 2

Game link Here if you want to go check it out:
Meetings (Custom Server Creation) - Roblox

5 Likes

I can research teleport service and all I just need more information on how it will really work

1 Like

If what you meant is a server browser, you can make it so that when the server is set to public, it saves as a table in the DataStore (general and not unique DataStores in this case). Clicking on the specific server, teleports you there using the TeleportToPrivateServer API.

2 Likes

Yeah there were videos on server lists I just could not find videos on this thanks!
So just to be clear I can use TeleportToPrivateServer API for this to work? And sorry for all the questions but how would the game know which private server to telelort to with the code. And if there are any videos that you know of that could help that would be good if you could send a link. Once again sorry for all the questions.

The ReserveServer API generates random keys, that if used with the TeleportToPrivateServer API, can teleport you to a specific private server. All keys are randomly generated and managed by Roblox and will be different everytime so no key is generated twice.

Here are some videos:
DevKing (covers the whole TeleportService API):
Advanced Roblox Scripting Tutorial #25 - Teleport Service (Beginner to Pro 2020) - YouTube

2 Likes

So an example would be… the player joins a reserved server and I bet there is a way to see the code. And if another player puts into a textbox that code and runs the teleport command using the text it would work fine? And to ensure the player goes into the same reserves server every time it saves the private server id than when the player teleports to there server it uses that. And if there is a way to see the id is it covered on how to do that in the video if now how would I do that

Yup, as long as the server stays up, when the player inputs that code he will get teleported to the server. And yes save it to a DataStore of the player that created the server.

I can try and put it the place as an .rblx file so you can go eexplore and see how I made it.

1 Like

Main place (create and join):
meetings-mainplace.rbxl (56.9 KB)

Teleport to place:
meetings-teleportto.rbxl (38.8 KB)

5 Likes

Thank you so much! I will be tweeking and playing around with it and than eventually copying and pasting and editing to work with my game thank you so much I will make sure to give you game credit for helping with one of the main things in my game!!

1 Like

I would also recommend getting a DataStoreEditor: Free DataStoreEditorPlugin - Roblox to manually edit and view the data store.

And also tell me when the game is finished, I will definitely check it out.

1 Like

Thanks! I was also already thinking about getting that plug-in thanks for the reassurance!! I will make sure to send you the link when we at least have beta out!

1 Like

One last thing make sure the server you’re teleporting too is a sub-place of the game, otherwise it might not work properly.

1 Like

Just a quick question. So lets say the data such as serverid fails to save would it be the end of the world or would the player easily be able to create another? Also do you think this would be hard to integrate into working with datastores 2?

You can add a way for the player to create/change the ID in the second server, you just need to create a textbox frame, they finish typing, you can detect it with TextBox.FocusLost (when user presses enter or stops editing the textbox) you can then FireServer with a RemoteEvent, and save the ID that way, just make sure they save to the same key so it doesn’t cause issues. And for the second question, I’ve never used DataStore2 so I don’t know if works.

And also the part where I do RemoveAsync is so the randomly generated ID can be used again without causing issues.

1 Like

@aren1toross Is the download place available for everyone (Like for example, I could download it and use it)?

(Sorry if I pinged you, I just wanted to get attention)

Yes, it’s free, feel free to use it however you want. Just follow the few steps I put out afterwards to be sure it works.

Ok, thank you very much, that will help alot! :smiley:

1 Like