Just a quick one, is there a way to add up the total values of every players cash for example on a leader board?
Add up leaderboard values into total?
3 answers
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
Works fine
And just for clearance, i'm not some beginner. This was such a basic question, but I've had a long day.
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.
4 comments
Thanks, that will do fine. I'm much more adept than that question makes me sound, just a brain dead moment.
Np, didn't want to give it out completely, because we're not really supposed to, but I decided to just do it this time, because I was at your point before and I hated it.
You're still fairly new to answering questions, Crazy, so here is another tip: Always make sure to explain your answer - not explaining it is basically just being lazy and often doesn't help the person in need that much.
You're still fairly new to answering questions, Crazy, so here is another tip: Always make sure to explain your answer - not explaining it is basically just being lazy and often doesn't help the person in need that much.
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
1 comment
I wasn't requesting for a script or anything in the first place, just a concept. I really should have worked it out on my own It's just too late at night for me (: but thanks anyway.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Glad I helped.