Ad
Log in to vote
0

Wins is not a valid member of Folder?

Asked by 13 days 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 59 — 13d
0
Wins is being created Altbotnot 9 — 12d

1 answer

Log in to vote
2
Answered by 13 days 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