i’m trying to load servers from my experience’s place, but even when i open 2 servers in that place, it only shows one server!!!
code from the place i want to get the servers from
local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("buildModeServers")
local key = math.random(1, 1000000000)
function saveData()
print(key)
local servers = {}
local serverData = {}
--[[1]] table.insert(serverData, game.ReplicatedStorage.owner.Value)
--[[2]] table.insert(serverData, game.JobId)
--[[3]] table.insert(serverData, #game.Players:GetPlayers())
--[[4]] table.insert(serverData, game.ReplicatedStorage.maxPlayerCount.Value)
--[[5]] table.insert(serverData, game.ReplicatedStorage.BUILD_NAME.Value)
--[[6]] table.insert(serverData, game.ReplicatedStorage.discoverable.Value)
--[[7]] table.insert(serverData, game.ReplicatedStorage.FPS.Value)
--[[8]] table.insert(serverData, key)
table.insert(servers, serverData)
ds:UpdateAsync("buildModeServersData", function()
return servers
end)
end
wait(2)
saveData()
local function playerRemoving(player)
print(#game.Players:GetChildren())
if #game.Players:GetChildren() == 0 then
print("a")
game.ReplicatedStorage.discoverable.Value = false
saveData()
end
end
game.ReplicatedStorage.save.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.save2.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.save3.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.save4.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.save5.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.load.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.load2.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.load3.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.load4.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.load5.OnServerEvent:Connect(saveData)
game.ReplicatedStorage.discoverable.Changed:Connect(saveData)
game.Players.PlayerRemoving:Connect(playerRemoving)
game.Players.PlayerAdded:Connect(saveData)
while wait(10) do
saveData()
end
code from the experience to get and load the servers
local dss = game:GetService("DataStoreService")
wait(2)
function loadServers()
local ds = dss:GetDataStore("buildModeServers")
local effects
local data
local successfully, ERRORMSG = pcall(function()
data = ds:GetAsync("buildModeServersData")
end)
if not successfully then
print(ERRORMSG)
end
if data then
local success, errorMSG = pcall(function()
local function addBuild(dataTab)
if typeof(dataTab) == "table" and not game.ReplicatedStorage.serversFolder:FindFirstChild(dataTab[1])--[[ and tonumber(data[3]) ~= 0 and data[6] == true ]]then
--[[ 1 ]] local owner = Instance.new("StringValue", game.ReplicatedStorage.serversFolder)
owner.Name = dataTab[1]
--[[ 2 ]] local id = Instance.new("StringValue", owner)
id.Name = "serverID"
id.Value = dataTab[2]
--[[ 3 ]] local count = Instance.new("IntValue", owner)
count.Name = "playerCount"
count.Value = dataTab[3]
--[[ 4 ]] local max = Instance.new("IntValue", owner)
max.Name = "maxPlayers"
max.Value = dataTab[4]
--[[ 5 ]] local buildName = Instance.new("StringValue", owner)
buildName.Name = "buildName"
buildName.Value = dataTab[5]
--[[ 6 ]] local discover = Instance.new("BoolValue", owner)
discover.Name = "discoverable"
discover.Value = dataTab[6]
--[[ 7 ]] local FPS = Instance.new("IntValue", owner)
FPS.Name = "FPS"
FPS.Value = dataTab[7]
--[[ 7 ]] local key = Instance.new("IntValue", owner)
key.Name = "buildKey"
key.Value = dataTab[8]
end
end
effects = data
local builds = game.ReplicatedStorage.serversFolder:GetChildren()
for i, v in pairs(effects) do
if v ~= nil then
local dataTable = effects[i]
addBuild(dataTable)
end
end
for i , v in pairs(builds) do
if v.owner.Value == v.owner.Value then
v:Destroy()
end
end
for i, v in pairs(game.ReplicatedStorage.serversFolder:GetChildren()) do
if v:IsA("StringValue") then
if v.playerCount.Value == 0 then
v:Destroy()
end
end
end
end)
if not success then
warn(errorMSG)
end
end
end
game.ReplicatedStorage.serversFolder:ClearAllChildren()
loadServers()
game.ReplicatedStorage.refreshBuilds.OnServerEvent:Connect(function()
game.ReplicatedStorage.serversFolder:ClearAllChildren()
loadServers()
end)
while wait(60) do
game.ReplicatedStorage.serversFolder:ClearAllChildren()
loadServers()
end
please help i’m literally about to lose it