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

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

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

✓ Accepted answer

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)

3 comments

0

Thanks, it works, but the currency gets reset to 0 from the initial of 100 (set using a function inside the module)

0

Edited, try something like that

0

thanks now it works

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