Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to increase a currency value for a single player ?

Asked by 6 years ago

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)
0
Are you trying to clone Cash and Stats into player? User#21242 20 — 6y
0
No, that's done, I'm trying to increase the value LordTechet 53 — 6y
0
Why are you moving things around to either the same place or somewhere new after setting a variable? User#21242 20 — 6y
0
Because I don't know how I could increase the value ! The currency script was made by another script ! LordTechet 53 — 6y
View all comments (2 more)
0
Hmm did you try removing lines 6 and 7? User#21242 20 — 6y
0
Yes LordTechet 53 — 6y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago
Loot.ClickDetector.MouseClick:Connect(function(playerWhoclicked)
        if playerWhoclicked then
               playerWhoclicked.leaderstats.IntValue.Value = playerWhoclicked.leaderstats.IntValue.Value + 10
        end
end)
Ad

Answer this question