Inventory transfer bug: Previous product keeps losing stock when selecting a new product

Hi! I’m still experiencing a strange inventory transfer bug in GDevelop, and I can’t figure out what’s causing it.

Here is exactly what happens:

  1. I click the 10 button to select a transfer quantity of 10.

  2. I click the CPU button, and 10 CPUs are correctly deducted from the main inventory.

  3. Then I click the Case button, without clicking the 10 button again. The game deducts another 10 CPUs AND another 10 cases.

  4. If I click the CPU button again without clicking the 10 button, it deducts another 10 CPUs.

It seems that the selected quantity or transfer action is not being reset correctly, and the previous product selection is somehow still affecting the inventory.

I want the game to deduct inventory only when I explicitly select the quantity and the product, and each transfer should happen only once. Selecting a different product should not deduct anything from the previously selected product.

Has anyone experienced this issue in GDevelop? What could be causing it, and how can I fix it?

Thank you for your help!

3

I don’t know this language

I understand that the variable names are in Hebrew, but if you can look at the logic, conditions, and actions, the language itself shouldn’t be a major obstacle. I’d really appreciate it if you could take a look at the logic and help me understand what might be causing the issue. Thank you for your time!

It’s a little hard to understand what’s happening, but in both event groups at the end you’re setting SelectedAmount to 0 and to 10, which happens one after another in the same frame. I think that might be the cause of the issue.

Your condition is

SelectedAmount = 10

SelectedProduct = X

Then you trigger an action to change some variables, and set SelectedAmount to 0 and then back to 10, so by the end of this event, you still end up with:

SelectedAmount = 10

SelectedProduct = X

So, your condition may still be valid. Maybe that’s why it’s not resetting?

Thank you for your suggestion! I removed the action that sets SelectedAmount back to 10 after setting it to 0, but unfortunately, the problem still persists.

The issue is that after I select the quantity 10 and click the CPU button, 10 CPUs are deducted correctly. However, when I select another product, such as the case, another 10 CPUs are deducted along with 10 cases, even though I didn’t click the quantity button again.

Also, clicking the CPU button again without selecting a quantity still deducts another 10 CPUs.

Do you have any other ideas about what might be causing this behavior? I really appreciate your help!

What type of variable is SelectedProduct? Just a text or an array or structure?

I don’t see that you reset this value anywhere, so depending on what type it is, it could also be an issue.

Also, in the condition, where you check if the SelectedProduct is “X”, is that an object group?

SelectedProduct is a global text variable. It stores the name of the selected product button, for example “כפתור_SSD”.

In the condition, I compare SelectedProduct to the button’s name as text. It is not an object group.

I haven’t been resetting SelectedProduct, because I thought selecting a new product would overwrite the previous value. Could that be causing the issue where the previous product’s stock is deducted again even when I don’t select the quantity button?

צילום מסך 2026-10-29 135055

If it’s a single global variable, then it’s value should be replaced when you click on the next item, but:

  1. I would reset the value after the number is deducted to be safe, unless you specifically want to allow to keep the selection.
  2. I would use an object group for the shop items. Right now you are duplicating the code: you have the red event group, and the blue event group. They do the same thing but for a different shop item - that could potentially introduce a timing issue, and could be why it’s applying the deduction twice. Let’s say you have CPU, GPU, RAM, etc. I would create a group, e.g. PC_Parts or Shop_Items, etc. Add all those items there, and then use only one event group:
  • Cursor is on Shop_Items & Left button is pressed = change SelectedProduct to Shop_Items

By hovering over a specific item, you’re already filtering the items, so the correct item should be set in the variable.

Thank you so much for your help! It worked! The inventory system is finally working correctly. I really appreciate you taking the time to help me figure this out. Thanks again!

Great! Good luck with the game :slightly_smiling_face:

I couldn’t read the operations

It’s working now, Thank you