Context - https://scriptinghelpers.org/questions/62139/is-a-single-player-lobby-to-a-connected-multiplayer-reserved-server-possible
Really suck at explaining things so hopefully this is thorough
I've made some progress with the help of roblox wiki and am able to prevent other players from joining after the game starts. When it does start the reserved server code is set to 0 in the datastore.
Now my problem, if the server is full before it starts anyone that tries to join a match can't until the match starts instead of creating a new server.
Now the game does start instantly when 5 players join so new servers would be opened, but I don't fully trust this. Say if I wanted to wait a certain time before I start the match to check to make sure no one leaves before the game starts. Others would receive server full while trying to join
This is the script in the single player lobby
local TS = game:GetService("TeleportService") local Players = game:GetService("Players") local DSS = game:GetService("DataStoreService") local DS = DSS:GetGlobalDataStore() GameMode = 324546364 - fake id just cause -- Get the saved code game.ReplicatedStorage.Events.Teleport.OnServerEvent:connect(function(plr) local code = DS:GetAsync("Test02") if type(code) ~= "string" then -- None saved, create one code = TS:ReserveServer(GameMode) DS:SetAsync("Test02",code) end game.ServerStorage.PlayerStats:WaitForChild(plr.Name).ServerId.Value = code TS:TeleportToPrivateServer(GameMode,code,{plr}) end)
and when a game does start this is fired from the reserved server.
local TS = game:GetService("TeleportService") local Players = game:GetService("Players") local DSS = game:GetService("DataStoreService") local DS = DSS:GetGlobalDataStore() DS:SetAsync("Test02", 0)