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

How to increase a currency value for a single player ?

I have a leaderstats money currency script, but it is fine, working. Now I wish to increase the value of the currency for a player by clicking on an object with ClickDetector. I'm struggling with it, help please ?

local Loot = script.Parent
local Player = game.Players.LocalPlayer
local Cash = Player.leaderstats.IntValue
local Stats = Player.leaderstats

	Cash.Parent = Stats
	Stats.Parent = Player

function OnClicked()
	Cash.Value = Cash.Value+10
end

Loot.ClickDetector.MouseClick:connect(OnClicked)

6 comments

0

Are you trying to clone Cash and Stats into player?

0

No, that's done, I'm trying to increase the value

0

Why are you moving things around to either the same place or somewhere new after setting a variable?

0

Because I don't know how I could increase the value ! The currency script was made by another script !

0

Hmm did you try removing lines 6 and 7?

0

Yes

1 answer

✓ Accepted answer
Loot.ClickDetector.MouseClick:Connect(function(playerWhoclicked)
        if playerWhoclicked then
               playerWhoclicked.leaderstats.IntValue.Value = playerWhoclicked.leaderstats.IntValue.Value + 10
        end
end)

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