The problem is that the “mouse button released” condition is true for the entire frame (all the event sheet). GD will read the events in the specified order:
Event 4: If you press the “button 1”, you delete it and create a “button 2” at the same position.
Event 7: Just after that, the condition “mouse button released” is still true, and the mouse is now over “button 2”, so it is deleted and a “button 3” is created at the same position.
So finally you delete the first button, create the second and delete it in one frame, to fix it you can:
Move the events 5, 6 and 7 over event 2 (events related to “button 2” over events related to “button 1”). This way, when you click the “button 1”, GD will read events related to “button 2” firstly, nothing will happen because there are no “button2” on the scene, and then will read events related to “button 1”, delete it and create a “button 2”. The next time you make a click “button 2” will be deleted as you would expect.
Add an “else” variable:
The last option is elegant and you can keep the natural order of events. The first button event doesn’t need the condition “else = 1”, but you can put it if you want and it will work, the last button event doesn’t need the action “else = 0”, but you can put it if you want and it will work
Would you mind to change the language to english and make that screenshot again?
I didn’t and I won’t take the time to figure out what language would that be and what events you actually been using, but now you made me curious…