On Button touch if enough money then subtract by price

Hey guys how do I make a shop so when you have enough of something and you press the buy button it subtracts the price.

My code below

_local widget = require (“widget”)
print(numonscreen)
local money = 10000
local mypics = {“regularhouse.png”}

local rectangle = display.newRect(160,200,275,400)

local buy = widget.newButton
{
    left = -45,
    top = 350,
    id = “buybtn”,
    label = “Buy”,
    
}

local newcard = widget.newButton
{

    left = 160,
    top = 350,
    id = “newcardbtn”,
    label = “New Card”,

     

}

local onTouch
local someNewText
local centerX = display.contentCenterX
local centerY = display.contentCenterY

      local moneydis = display.newText(money,50,50)
moneydis:setFillColor(1,0,0)
function someNewText1(  )
    – body
    moneydis.moneydis =  moneydis - 100
    transition.to(moneydis,{time = 100, alpha = 2})
end
function onTouch1(event)
    
    if (event.phase == “began”) then
                
                print(“it began”)
                transition.to(event.target1,{time = 100, alpha = 0, onComplete = someNewText1} )
                print(moneydis)   
                local moneydis = display.newText(money,50,50)
                moneydis:setFillColor(0,255,0)
                moneydis:removeSelf()
    end
end
buy:addEventListener(“touch”,onTouch1)
    
    
local text = display.newText(math.random(1000,10000),centerX,centerY,nil,40)
text:setFillColor(1,0,0)

function someNewText()
    text.text = math.random(1000,10000)
    transition.to(text, {time = 100, alpha = 1})
end
function onTouch(event)
    
    if (event.phase == “began”) then
                
                print(“it began”)
                transition.to(event.target,{time = 100, alpha = 0, onComplete = someNewText} )
        local r = math.random ( 1, #mypics )local item = display.newImage ( mypics[r], 150, 150 )
        local newcard1 = widget.newButton
        {
            left = 160,
            top = 350,
            id = “newcardbtn1”,
            label = “New Card”,
        }
    
       
        newcard1:addEventListener(“touch”,onTouch)
    end
end
    text:addEventListener(“touch”,onTouch)
local moneydisp = display.newText(money,50,50)
moneydisp:setFillColor(1,0,0)_