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

How do I change the roblox's leaderboards money count?

I tried this in a script but I couldn't find a leaderboard object so I created one along with the code to add money but then when i tested it it didn't work can someone help

	local brick = script.Parent
	 
	function onTouched(hit)
	    for i,player in ipairs(game.Players:GetPlayers()) do
	        if player.Character then
	            local stat = player:FindFirstChild("leaderstats")
	            if stat then
	                player.leaderstats.Money.Value = player.leaderstats.Money.Value +1
	                brick:Destroy()
	            end
	        end
	    end
	end
	 
	 
	brick.Touched:connect(onTouched)

btw sorry for possible confusion first question

2 comments

0

Where do you create the leader stats?

0

I'm assuming he didn't create a leaderstat folder inside the player when they joined, otherwise this would've worked.

1 answer

✓ Accepted answer

You can't just create a leaderstats object in studio, you need to bind with PlayerAdded and add a leaderstats value and then a money value under the leaderstats value. I'll provide an example below.

game.Players.PlayerAdded:connect(function(player)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local money = Instance.new("IntValue")
	money.Name = "Money"

	stats.Parent = player
	money.Parent = stats
end)

This should not be in a brick that will be destroyed but in a script in workspace or ServerScriptService

2 comments

0

This is creating a leaderstats, not changing a current one's value. -_-

1

Well, you have to create one first to be able to changing the current value. Because of what I'm seeing, he doesn't have a leaderstat and money value inside of the player, thus creating no leaderboard data.

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