queue_free wont work under specific curcumstances

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LeafSal

I have a program that draws lines when a player holds down their mouse.
I want to have a button that deletes the players last drawn line, and the code works, but not when I use a button to activate the function where I have that code.

(Code in question)

Now I know for a fact that I can find the node Line2d that I want to delete since I can print it, but for some reason when a call the function to delete it it doesn’t work if I called it with a texture button. There are no errors ether, it just accepts the node and doesn’t do anything.
When I call deleteLast using that _on_ColorRect_mouse_entered(), for example, it works as intended.
Using free() and remove_child() dosent work ether.

Here is something funny, If I draw the line while pressing the button, it will actually work for some unholy reason.

what’s the code for the texture button?

exuin | 2023-02-25 09:44

It was just connected using an On pressed function, the button had no code itself

LeafSal | 2023-02-25 15:58