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

Add up leaderboard values into total?

Just a quick one, is there a way to add up the total values of every players cash for example on a leader board?

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.

1 comment

1

Glad I helped.

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

0

Thanks, that will do fine. I'm much more adept than that question makes me sound, just a brain dead moment.

1

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.

2

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.

0

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

0

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.