How would I make a server list/ server list UI?
I’ve tried making it with datastores like this:
local serverList = game:GetService("DataStoreService"):GetDataStore("ServerList")
if not game:GetService("RunService"):IsStudio() then
if serverList:GetAsync("ServerList") == nil then
serverList:SetAsync("ServerList", {})
end
local list = serverList:GetAsync("ServerList")
if not list[game.JobId] then
local list = serverList:GetAsync("ServerList")
table.insert(list, game.JobId)
serverList:SetAsync("ServerList", list)
print("Hey")
end
game.OnClose:Connect(function()
if list[game.JobId] then
table.remove(serverList:GetAsync("ServerList"), game.JobId)
serverList:SetAsync("ServerList", list)
print("Hey")
end
end)
serverList:OnUpdate("ServerList", function()
print("Server!")
for _, v in pairs(serverList:GetAsync("ServerList")) do
print(v)
end
end)
end
But it doesn’t work because “Argument 1 missing or nil” on line 4 which I don’t know why.