Hey hey! I’m making some type of lobby system where the player can join a server via a list. I’m looking for some guidance for a list that will display all currently open servers even if no players are connected to the hub game. Is there some service I can call for this?
It’s really asking a question. I’ve got the reserved server I’m just wondering would a loop display this server when there is no one in the hub game and a new player joins?
local DataStoreService = game:GetService("DataStoreService")
local GlobalDataStore = DataStoreService:GetGlobalDataStore()
local function addServer(accessCode)
local success, data = pcall(function()
return GlobalDataStore:GetAsync("GlobalServerList") or {}
end)
if success then
table.insert(data, accessCode)
local writeSuccess = pcall(function()
GlobalDataStore:SetAsync("GlobalServerList", data)
end)
end
end
local function getServers()
local success, servers = pcall(function()
return GlobalDataStore:GetAsync("GlobalServerList")
end)
if success then
return servers
end
end
--run TeleportService:ReserveServer() as usual
--run getServers() when you want a table of servers and addServer() when you want to add a server