Delete a specific object

Hy

In my platformer game, the player can creates bubbles when you push the button z (i did that part). Now, i don’t want more than 2 bubbles created on the scene. Each time, the player create a bubble, i want the older one to be deleted. The idea is when bubble number 3 is created, i want bubble number 1 to be deleted. When bubble number 4 is created, bubble number 2 is deleted…

I read all the post about that the subject and i came up with this.

In the last line when the condition is “the scene variable id_object > 2”
i want to add this action “delete bubble with id object -2 of the number of the new bubble”

Condition
variable I’d of bubble = variable (id_object)-2
Action
delete bubble.

thanks for the response.
I did what you say but i must be doing something wrong.
Nothing is deleted.

you need to create your bubble first, or gd does not know which id is supposed to be set.

Thanks.
I did a copy-paste of exactly what you said to me but it doesn’t work.
I can create more than 2 bubbles (i can create 3,4,5…).
I think the solution is to change the action part and to add in the action part “delete bubble with id = variable(id)-2” ? What you think ?

What I showed works.
You did not do the exact same thing then.
The order of the events matter

A big thanks.
It didn’t work because for one event, i didn’t follow the order.