Object subtracting quantity from two items instead of just one

when I unlock the door it subtracts the two items instead of just one, how do I solve this?

Video:

Remove item blueprint:

Door code:


A quick fix would be to add a “DO_ONCE” node, assuming the code is firing multiple times, which it may be.

Either that, or there’s a variable that’s incorrect.

Hey @KaytlynCatter

you are using a ForEachLoop to check your inventory (2. picture). So every position in the inventory, in this case slot 0 and slot 1 are checked. If there is a key, remove 1 of its quantity.

  • You could use a boolean to check if you already removed an item. This boolean can then be reseted on the Completed pin of the ForEachLoop.
  • You could change the way your items are stored. E.g. your 6 keys would be stored as 6 keys in your inventory variable and would just be displayed differently (stack size). So your ForEachLoop would only find those 6 keys as one entry and then subtract one

thanks guys, both solutions were useful and fixed my problem!!! :smiley: