I am making a Server List system, it works. But when I create a new one / refresh the GUI, it throws the error in the title.
Extra Info (EDIT): This is happening when I use it after my friend used it.
local ServersFrames = {}
local Update_Gui = function()
ServersFrames = {}
table.clear(ServersFrames) -- // Just incase lol
for _, ServerVal in pairs(game:GetService('ReplicatedStorage'):WaitForChild('Servers'):GetChildren()) do
local name = ServerVal.Name
local serverStats = string.split(ServerVal.Value, ' ')
local id = serverStats[1]
local plrs = serverStats[2]
for i,v in pairs(workspace:WaitForChild('serverboard'):WaitForChild('SurfaceGui'):WaitForChild('ScrollingFrame'):GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
local serversFrame = script:WaitForChild('Server'):Clone()
serversFrame:WaitForChild('ServerName').Text = name .. "\n ID: " .. id
serversFrame:WaitForChild('Playeramount').Text = plrs .. "/" .. game:GetService('Players').MaxPlayers
table.insert(ServersFrames, serversFrame)
serversFrame:WaitForChild('Join').Activated:Connect(function()
game:GetService('ReplicatedStorage'):FindFirstChild('JoinServer'):FireServer(id)
end)
for _, serverFrame in pairs(ServersFrames) do
if serverFrame ~= nil then
serverFrame.Parent = workspace:WaitForChild('serverboard'):WaitForChild('SurfaceGui'):WaitForChild('ScrollingFrame')
end
end
end
end
workspace:WaitForChild('servercreater'):WaitForChild('SurfaceGui'):WaitForChild('Creater'):WaitForChild('Join').Activated:Connect(function()
game:GetService('ReplicatedStorage'):WaitForChild('CreatePrivate'):FireServer()
end)
game:GetService('ReplicatedStorage').Servers.ChildAdded:Connect(Update_Gui)
game:GetService('ReplicatedStorage').Servers.ChildRemoved:Connect(Update_Gui)