I’m trying to make it so that it gets every server owned by the player from the server, send to the client then shows it in a UI, No servers show, Could somebody help me out
local DataStoreService = game:GetService("DataStoreService")
local ServerDataStore = DataStoreService:GetDataStore("ServerStore")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FetchOwnedServersEvent = ReplicatedStorage:WaitForChild("PrivateServerSystem"):WaitForChild("FetchOwnedServers")
local function GetOwnedServers(player)
local success, serverKeys = pcall(function()
return ServerDataStore:GetAsync("ServerKeys") or {}
end)
local ownedServers = {}
if success then
for _, serverKey in pairs(serverKeys) do
local successFetch, serverData = pcall(function()
return ServerDataStore:GetAsync(serverKey)
end)
if successFetch and serverData then
if serverData.creator == player.UserId then
table.insert(ownedServers, serverData)
end
end
end
else
warn("Failed to load server keys: " .. tostring(serverKeys))
end
return ownedServers
end
FetchOwnedServersEvent.OnServerEvent:Connect(function(player)
local ownedServers = GetOwnedServers(player)
FetchOwnedServersEvent:FireClient(player, ownedServers)
end)