I am trying to add a button that increase the efficiency of money production and the amount of money they can hold. But, my code is not working. I checked to make sure that the function was running but it wasn’t.
local moneyCount = 0 local moneyWallet = 500 local moneyLVL = 2 local costToUpgrade = 200 local increasePerTime = 500 local function upgradeMoney(event) if event.phase == "began" then increasePerTime = increasePerTime - 400 end end local function increaseMoney() if moneyCount == moneyWallet then else moneyCount = moneyCount + 1 moneyText.text = tostring(moneyCount) .. " / " .. tostring(moneyWallet) end end local moneyCounterTimer = timer.performWithDelay(increasePerTime, increaseMoney, 0) upgradeCapEfi:addEventListener("touch", upgradeMoney)
The problem is that the upgradeMoney function should reduce the increasePerTime variable seen in the timer. But, this does not work and the money production stays the same. Any help would be great!