I have this game, it’s basically roblox inside of roblox. In that game, I have user made games. How can I have one server per one of those games inside of the actual game that they get teleported to, rather than creating 5000 game instances.
I think I may be able to help you with this, but I’m going to ask for some clarification first - when you say “user made games”, do you mean a place inside your game/universe, or an entirely different game/universe?
It’s like Roblox inside of Roblox. I teleport them to another game instance inside of the main game, and load what they created.
Ok I see, thanks! My recommendation is to create one unique reserved server code per user-generated game. This is an example of that from the developer site:
local TS = game:GetService("TeleportService") local Players = game:GetService("Players") local DSS = game:GetService("DataStoreService") local DS = DSS:GetGlobalDataStore() -- Get the saved code local code = DS:GetAsync("ReservedServer") if type(code) ~= "string" then -- None saved, create one code = TS:ReserveServer(game.PlaceId) DS:SetAsync("ReservedServer",code) end
In their example, they just have one reserved server. But in your case, I would just generate the code when a place gets “created” if your code works like that. (Or, check it when someone goes to play that game, whatever works in your case.)
This will allow players to always join the same server of that game, assuming the server is not full! If that first server fills up, Roblox will automatically provision a new game under that same reserved server code, but with a new job id.
If you want to limit it to only one server per game, you could use a Memory Store to indicate whether a game already has a server associated with it. If so, you can put the server’s job id with the user’s created place id into the memory store, and check when the player arrives if the job id of that server matches the job id of the server they arrived in. If it does, great! If not, you can return them to the lobby and tell them that server is full.