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

How do I add a amount displayed in a value to leaderstats?

There is a value that is displayed on a money printer.

https://imgur.com/a/Qtw1P - Picture

That value is increased over time and the money is displayed every 3 seconds.

https://www.youtube.com/watch?v=wVr-INVnQsw&feature=youtu.be - Example Video

I want to add that value to Leaderstats value in the Local Player so they get more money upon clicking "Collect"

In a localscript in the "Collect" button, this is displayed but it does not function:

repeat wait() until game:GetService("Players").LocalPlayer
local stats = game.Players.LocalPlayer.leaderstats.Value

script.Parent.MouseButton1Click:connect(function(player)
	stats = stats + script.Parent.Parent.Amount.Value.Value
end)

How do i grab the leaderstats in the local player and add whats in the value to the leaderboard?

2 comments

0

You don't require to wait for the player, as the script'll fire when the player loads. (Not counting the player's Character, PlayerGui, Backpack, etc.) Could you please explain more in-depth about what you're trying to accomplish?

0

Doesnt work.

1 answer

Well you can’t do an adition with a NumberValue you have to do an addition of the NumberValues value. I suggest adding an extra .Value to local stats and see if that works. I am having trouble understanding your question so write back to me if this doesent work with a better explanation.

3 comments

0

I do not fully understand what you mean. Leaderstats is a NumberValue in the Local Player. The value in the numbervalue is transferred to the leaderboard displaying how much money the player has. There's a NumberValue in the amount of money that's displayed on the printer. I want to add that amount in the number value to leaderstats.

0

Badically you are multiplying something that you cannot multiply. When multyplying a value you do (Name Of Vale).Value

0

That's what i'm doing. Leaderstats is the name of the value im adding to.

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