Why isnt my sword equpping working?

why isnt my sword equipping working. I can equip the sword but not unequip it. Here is my sword equpping code.

My full code:





Not related to your issue, but something you should change - you do not need to Repeat for each object and test if a click happened on it. This is not the optimal and most efficient way to use GDevelop. When you check for a touch on items, GDevelop will then only use the item object(s) that meet that condition in’that event and it’s subevents; it effectively filters the usage of items to just the one that matches the condition.

So, get rid of that “Repeat for each instance of items” event, but keep those other events.



Onto the issue. This is a common example where one event sets things up for the next one to happen. The two red-boxed actions make the object and variable ready, so the next event sees them as true. The first event puts the sword in the hotbar slot, but then right after, it moves it back to the sword slot.

A quick fix would be to add the two green conditions. This would ensure only one of the events are actioned, not both.

1 Like

thanks a lot, it works now