I’m trying to make a custom leaderboard. It is all updating correctly once, but won’t update after that. The “Updating…” and “updated” messages print, but nothing else. It does not update on the GetPropertyChangedSignal()
lines, and there are no errors or warnings in the output.
I’ve tried everything I can, from coroutine
to pcall()
, to restarting Studio and my whole computer.
Any help is appreciated, I am completely stumped on this one.
local players = game:GetService("Players")
local sGui = game:GetService("StarterGui")
local statsFrame = script:WaitForChild("PlayerStats")
local mainFrame = script.Parent:WaitForChild("MainFrame")
local displayFrame = mainFrame:WaitForChild("PlayersDisplay")
local ranks = {
["Beginner"] = Color3.fromRGB(77, 77, 77),
["Rookie"] = Color3.fromRGB(170, 0, 0),
["Intermediate"] = Color3.fromRGB(255, 85, 0),
["Experienced"] = Color3.fromRGB(0, 85, 255),
["Pro"] = Color3.fromRGB(0, 85, 0),
["Awesome"] = Color3.fromRGB(255, 255, 0),
["Amazing"] = Color3.fromRGB(0, 85, 255),
["Expert"] = Color3.fromRGB(255, 170, 0)
}
local function update()
print("Updating...")
for _, item in ipairs(displayFrame:GetChildren()) do
if item:IsA("UIListLayout") then continue end
item:Destroy()
end
for _, player in ipairs(players:GetPlayers()) do
local leaderstats = player.leaderstats
local rank = leaderstats.Rank
local wins = leaderstats.Wins
local elims = leaderstats.Knockouts
local clonedFrame = statsFrame:Clone()
local nameLabel = clonedFrame.PlayerName
local playerStats = clonedFrame.Stats
local elimsLabel = playerStats.Knockouts
local rankLabel = playerStats.Rank
local winsLabel = playerStats.Wins
clonedFrame.Parent = displayFrame
nameLabel.Text = "@"..player.Name
rankLabel.Text = rank.Value
rankLabel.TextColor3 = ranks[rank.Value]
elimsLabel.Text = elims.Value
winsLabel.Text = wins.Value
end
print("updated")
return true
end
local function loadStats(player:Player)
local leaderstats = player:WaitForChild("leaderstats")
local rank = leaderstats:WaitForChild("Rank")
local wins = leaderstats:WaitForChild("Wins")
local elims = leaderstats:WaitForChild("Knockouts")
local succeeded, failed = pcall(update)
if not succeeded and failed then
warn(failed)
update()
end
print("it managed to update :D")
rank:GetPropertyChangedSignal("Value"):Connect(update)
wins:GetPropertyChangedSignal("Value"):Connect(update)
elims:GetPropertyChangedSignal("Value"):Connect(update)
end
sGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
players.PlayerAdded:Connect(loadStats)
task.spawn(update)