Well this would be a good time to use firebase realtime database. Well first of all we need some sort of poller which constantly does get request from firebase. Then we need a thing where when a server is created it’s JOBID get’s added to the firebase parent node. Lastly when BindToClose is called on a server which is reserved we need it to be removed from the parent node in firebase.
local RunService = game:GetService("RunService")
local GameInfo = require(game.ServerScriptService.Modules.GameInfo)
local IsStudio = RunService:IsStudio()
function SetServer(Value)
GameInfo.Firebase.ServerList:UpdateAsync("Servers", function(OldData)
if type(OldData) ~= 'table' then
OldData = {}
end
OldData[game.JobId] = Value
return OldData
end)
end
if IsStudio == true then -- studio server doesn't have a JOBID
print 'studio doesnt worl'
else
print(game.JobId, " this is the ID")
SetServer(true)
end
game:BindToClose(function()
if IsStudio == true then
print 'p'
else
-- you have to remove the node from "servers'
GameInfo.Firebase.ServerList:DeleteAsync("Servers/".. game.JobId)
end
end)
while true do -- poller
local Data = GameInfo.Firebase.ServerList:GetAsync("Servers")
for ServerName,PlaceHolderValue in pairs(Data) do
print(ServerName)
end
wait(30) -- 30 second server update rate
end
Firebase module I used.
https://firebase.google.com/docs/firestore/quotas
Firebase limits for the free plan.
https://gyazo.com/08ba414e154b56998394684a647dd569
ANYWAYS Good thing universe scripts and temporary datastores are coming, then we can do this without the 50,000 read limit in firebase for the free plan. Sure you can buy the paid plan if you want though.
When universe scripts come this will be practical until now we’ll have to rely on buying other databases and using it. (50,000 read limit isn’t big enough for big games), that’s why we need the paid plan.
BUT YOU CAN MAKE A JOIN PERSON SYSTEM, THAT IS PRACTICAL TO DO.
https://developer.roblox.com/en-us/api-reference/function/TeleportService/GetPlayerPlaceInstanceAsync
https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPlaceInstance