Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Wins is not a valid member of Folder?

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)

2 comments

0

is Wins ever being created or are you simply trying to get it?

0

Wins is being created

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.