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

I'm trying to make a button that increases your money but it only works once?

Asked by 6 years ago

I'm trying to make a button that increases your current currency. I used this guide:

http://wiki.roblox.com/index.php?title=In_Game_Currency#CurrencyManager

And made my own script:

local click = script.Parent.ClickDetector.MouseClick
local curman = require(389753980)
local currentGold = {}
local updatecurev = game.ReplicatedStorage.UpdateCurDis

click:Connect(function(player)
    local balance = curman:GetBalance(player.UserId) + 1
    currentGold[player.UserId] = balance
    updatecurev:FireClient(player, balance)
end)

It updates the currency, but it only works once. What do I do?

1 answer

Log in to vote
1
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

I would update the gold based off of the current balance (not sure what's going on with the private module):

local click = script.Parent.ClickDetector.MouseClick
local curman = require(389753980)
local currentGold = {}
local updatecurev = game.ReplicatedStorage.UpdateCurDis

click:Connect(function(player)
    local balance = curman:GetBalance(player.UserId)
    if currentGold[player.UserId] then
        currentGold[player.UserId] = currentGold[player.UserId] + 1
    else
        currentGold[player.UserId] = balance
    end
    updatecurev:FireClient(player, currentGold[player.UserId])
end)
0
Thanks, it works, but the currency gets reset to 0 from the initial of 100 (set using a function inside the module) radusavin366 617 — 6y
0
Edited, try something like that mattscy 3725 — 6y
0
thanks now it works radusavin366 617 — 6y
Ad

Answer this question