Hello there,
I am trying make these script show a player count On a gui and It’s not showing a list of players. If someone could help my issue that would be great!
GUIHandler
local function updateGui()
local serverFrames = {}
for i, serverValue in pairs(game:GetService("ReplicatedStorage").Servers:GetChildren()) do
local name = serverValue.Name
local serverStats = string.split(serverValue.Value, " ")
local id = serverStats[1]
local plrs = serverStats[2]
local serverFrame = script.ServerTemplate:Clone()
serverFrame:WaitForChild("ServerName").Text = name .. "\n ID: " .. id
serverFrame:WaitForChild("Players").Text = plrs .. "/" .. game:GetService("Players").MaxPlayers
table.insert(serverFrames, serverFrame)
serverFrame.JoinButton.MouseButton1Click:Connect(function()
game:GetService("TeleportService"):TeleportToPlaceInstance(game.GameId, id)
end)
script.Parent.List:ClearAllChildren()
script.UIListLayout:Clone().Parent = script.Parent.List
for i, serverFrame in pairs(serverFrames) do
serverFrame.Parent = script.Parent.List
end
end
end
updateGui()
game:GetService("ReplicatedStorage").Servers.ChildAdded:Connect(updateGui)
game:GetService("ReplicatedStorage").Servers.ChildRemoved:Connect(updateGui)
ServerHandlers
local serversFolder = game.ReplicatedStorage:WaitForChild("Servers")
local ms = game:GetService("MessagingService")
ms:su("ServerList", function(data)
data = data.Data
if data.serverId ~= game.JobId then
local ServerValue = script.ServerName:Clone()
ServerValue.Name = "Server" .. #serversFolder:GetChildren() + 1
ServerValue.Value = data.serverId .. " " .. data.players
ServerValue.Parent = serversFolder
wait(5)
ServerValue:Destroy()
end
end)
while game.VIPServerId == "" do
local data = {
serverId = game.JobId,
players = #game:GetService("Players"):GetPlayers()
}
ms:PublishAsync("ServerList", data)
wait(5)
end
- Official_SimuIation