Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Wins is not a valid member of Folder?

Asked by 2 years ago

I have a leaderboard script, and I have a leaderboard for Cash, but when I play the game, it does not show Wins and Cash it just shows Cash.

Script:

for _, player in pairs(game.Players:GetPlayers()) do
    local stat = player.leaderstats.Wins --When the error appears

    WinsLB:SetAsync(player.UserId, stat.Value)
end

for _, frame in pairs(leaderboard.SurfaceGui.Holder:GetChildren()) do
    if frame:IsA("Frame") then
        frame:Destroy()
    end
end

updateLeaderboards()
wait(10)
0
is Wins ever being created or are you simply trying to get it? irid_leas 97 — 2y
0
Wins is being created Altbotnot 9 — 2y

1 answer

Log in to vote
2
Answered by 2 years ago

if you're constantly going to loop through the players and get their "Wins" its best if you wait for it or pass them and come back the next time. Theres a chance that a new player joined while you're looping and the stats have not been created yet.

for _, player in pairs(game.Players:GetPlayers()) do
    local stat = player:WaitForChild("leaderstats"):WaitForChild("Wins")
    WinsLB:SetAsync(player.UserId, stat.Value)
end
Ad

Answer this question