Just a quick one, is there a way to add up the total values of every players cash for example on a leader board?
Solved it from DaCrazy's answer.
while true do total = 0 players = game.Players:GetChildren() for i,players in pairs(players) do total = total + players.leaderstats.Status.Value end print(total) wait(1) end
And just for clearance, i'm not some beginner. This was such a basic question, but I've had a long day.
Although Scripting Helpers was made for help, and not requests, ill be nice this one time. Dont expect others being nice, though. It does get quite annoying when people request.
Anyways, all you would have to do is something like this:
local allcash = Instance.new("NumberValue", game.ReplicatedStorage) allcash.Name = "CashForEveryPlayer" allcash.Value = 0 for i,v in pairs(game.Players:GetPlayers()) do allcash.Value = allcash.Value + v.leaderboard.Cash.Value end
I don't want to give this out completely, because you wouldn't learn, and that isn't the purpose of this website, so, I hope this isn't doing that. You edit it around.
local total for _,leaderstat in pairs(player.leaderstats:GetChildren()) do total = total + leaderstat.Value end print(total) -- You can do whatever else you want with the total here.