Queue Free Single Player inventory

Godot Version 4

Hopefully this is simple -

In my game I have it where the player can collect gems - though it seems that when I collect them and then die to an enemy, the player does the die animation but does not ‘self.queue_free()’ and return to the main screen scene. I have tried to do just ‘queue_free()’ to see if that would get rid of the gems, but ran into the same issue. It does not pop up as an error in the debugger either.

Is there a simple way to code to remove items from a players inventory?

Thank you for your help!!

Can you share some more code with your dying logic and inventory logic?

Do you want to queue free the whole player, or the inventory, or just the collected items from the inventory?

Hey @wchc, I’m jumping in since I’ve faced a similar issue. If the player or inventory holds references to objects (like collected items), queue free() might not work as expected because those references can prevent proper cleanup. In my case, I had to manually clear the inventory data before calling queue free() on the player. It seems Godot 4 handles node lifecycles a bit differently, so cleaning up explicitly can help avoid lingering issues.

Im guessing you stored them in an array, you can simply use the method clear() , e.g inventory.clear()