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.
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.
Save it to the player that created the server ID as: ID-ReservedServerId
Save it the access code as: AccessCode
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.
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
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.
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.
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.
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!!
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!
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.