Messy code and code returning false not working

I’m making this function where i buy a specific weapon for a specific price and if the coins aren’t enough then it wouldn’t be executed. the else isn’t working and I’m repeating the code so is there any way to write more efficient code and fixing the else code block? buyW() is the function where i buy the weapon

let xp = 0
let hp = 100
let coins = 200

const button1 = document.querySelector("#button1")
const button2 = document.querySelector("#button2")
const button3 = document.querySelector("#button3")
const button4 = document.querySelector("#button4")
const button5 = document.querySelector("#button5")

const textbox = document.querySelector("#textbox")
const textbox2 = document.querySelector("#textbox2")

const xpNum = document.querySelector("#xpNum")
const hpNum = document.querySelector("#healthNum")
const coinsNum = document.querySelector("#coinsNum")

//intiallize button functions
button1.onclick = goToStore

xpNum.innerHTML = xp
hpNum.innerHTML = hp
coinsNum.innerHTML = coins

const villains = [
    {name: "Sandman", hp:25},
    {name: "Vulture",hp:50},
    {name: "Lizard",hp:75},
    {name: "Mysterio",hp:80},
    {name: "Green Goblin",hp:120},
]

let inv = [
    {name: "Spiderweb" , damage: 2}
]

let currentWeapon = ""

inv.forEach((item,index)=>{
    currentWeapon+=`${index + 1}. ${item.name}<br>`
})

const weapons = [
    {name: "Shield", damage: 5 , price: 50},
    {name: "Gun" , damage: 10, price: 100},
    {name: "Trident", damage: 20, price: 200}
]

let weaponsList = ""

weapons.forEach((item,index)=>{
    weaponsList+=`${index + 1}. ${item.name} - ${item.price} coins<br>`
})


const scenes = [
    //start screen
    {scene:"start",
    text: "Spiderman is near a mom-and-pop shop in Queens. What should he do?",
    btnT: ["Go to store","Go to city","Go to underground","Exit"],
    btnF: [goToStore,goToCity,goToUnder,exit]
    },
    //entering store
    {scene:"store",
    text: "Spiderman is inside the store. What should he do?",
    btnT: ["Buy Weapon","Sell Weapon","Buy Health - 15 coins","Leave Store"],
    btnF: [buyW,sellW,buyH,leave]
    },
    //buy weapon
    {scene: "buy",
    text: `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`,
    btnT: ["Shield - 50 coins","Gun - 100 coins","Trident - 200 coins","Exit Buy"],
    btnF: [weapon("Shield"),weapon("Gun"),weapon("Trident"),exitBuy],
    text2 : weaponsList 
    }
]

function update(scene){
    button1.onclick = scene.btnF[0];
    button2.onclick = scene.btnF[1];
    button3.onclick = scene.btnF[2];
    button4.onclick = scene.btnF[3];
    
    button1.innerHTML = scene.btnT[0];
    button2.innerHTML = scene.btnT[1];
    button3.innerHTML = scene.btnT[2];
    button4.innerHTML = scene.btnT[3];

    textbox.innerHTML = scene.text

    if(Object.prototype.hasOwnProperty(scene,"text2")){
        textbox2.innerHTML = scene.text2
    } else {
        textbox2.style.display = "none"
    }
}

function goToStore(){
    update(scenes[1])
}

function goToCity(){
    update(scenes[0])
}

function goToUnder(){
    update(scenes[0])
}

function exit(){
    update(scenes[0])
}
function buyW(){
    update(scenes[2])
    textbox2.style.display = "block"
    textbox2.innerHTML = scenes[2].text2
    if(coins >= 50){
        function shield(){
            alert("Shield bought!")
            coins-=50
            coinsNum.innerHTML = coins
            inv.push(weapons[0])
            currentWeapon = ""
            inv.forEach((item,index)=>{
                currentWeapon+=`${index + 1}. ${item.name}<br>`
            })
            textbox.innerHTML = `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`
            button1.removeEventListener("click",shield)
        }
    } else {
        alert("Not enough coins!")
        return false
    }

    if(coins >= 100){
        function gun(){
            alert("Gun bought!")
            coins-=100
            coinsNum.innerHTML = coins
            inv.push(weapons[1])
            currentWeapon = ""
            inv.forEach((item,index)=>{
                currentWeapon+=`${index + 1}. ${item.name}<br>`
            })
            textbox.innerHTML = `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`
            button2.removeEventListener("click",gun)
        }
    } else {
        alert("Not enough coins!")
        return false
    }
    
    if(coins >= 200){
        function trident(){
            alert("Trident bought!")
            coins-=200
            coinsNum.innerHTML = coins
            inv.push(weapons[2])
            currentWeapon = ""
            inv.forEach((item,index)=>{
                currentWeapon+=`${index + 1}. ${item.name}<br>`
            })
            textbox.innerHTML = `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`
            button3.removeEventListener("click",trident)
        }
    } else {
        alert("Not enough coins!")
        return false
    }
    button1.addEventListener("click",shield)
    button2.addEventListener("click",gun)
    button3.addEventListener("click",trident)
}

function sellW(){
    
}

function buyH(){
    
}

function leave(){
    update(scenes[1])
}

function weapon(weapon){

}

function exitBuy(){

}

update(scenes[0])```