A variable ist global. If you set x==2, x will be 2 in the whole game - as long you don't change it. The problem isn't
where you do this but
when you do this. It's important to think about which action can change the values and what happens before and after? Because you can use every object, every location, every scene to set a value or a condition it could be difficult to keep the overview. You need a lot of discipline.
I remember: you have a cupboard with an item in it. You need three pictures (objects) on your scene: cupboard closed, cupboard open with item to see and cupboard open without item. Don't think the item you see must be the same you take! It's only a picture to make the player think it is! So you need the single item too for putting into the inventory.
The value „cupboard-open“ may be 0 at start. The object is „cupboard closed“. If the character clicks on the cupboard, the value „cupboard-open“ changes to 1 (open is true). At the same time the object switches from a close Cupboard to an opened cupboard with item in there. On this new object you can choose to click for an action. After clicking the value „cupboard-open“ changes to 2, the object will change to a picture of a cupboard without item, the object is now „finished“. You have all done what you want to do. The cupboard will be open for the rest of the game. You can deactive them now, but the better way is to make a text by clicking: „You have already put the item“. Of course you need the same item to put into your item-bag. So long your value „cupboard-open“ will be 2 nothing else happens with the open cupboard. You never change the value from 2 to 0 back.
You can request „if cupboard-open == 1 then write some text else do this.“ It's almost better to control your situation. Not in every case but sometimes you get a condition it won't never be true and you have a „hang-on“.
Yes, it sounds complicated. But it's only getting used to.
After all: it's only ONE way. You can of course put the item as an extra object into the cupboard. But in both cases you need the item on the scene and the same item for the bag. You need the item twice.
Sorry, but it is VERY VERY exhausting to write this in English understandable...