equal” to 0, the button continues to give money when pressed, and when I set it to 1, it stops giving money on the last sword. However, I want it to stop giving money when my last sword in the inventory is depleted. How can I achieve this?
I think you just need to think about your order of operations.
If you want to be given money if you have a sword first check if Inventory sword > 0, if true then give money and then reduce the number of swords. No need to check if equal to 1, as long as InventorySword is greater than 0, you can “sell” one for money.
The issue that you’re getting here is that you’re reducing the number of swords before you’ve been paid, and then checking if you have any swords left to get paid for.