In this line, you’re deleting a specific Peg that is at this specific path on the tree that you specified there.
When it’s deleted the first time, you can’t logically delete it a second time, hence the error that you’re trying to delete something that has already been deleted.
At no point in your code are you trying to delete any other Peg than this one.
What you should do instead is to grab a reference to a Peg that the ball touched and delete that Peg. I’m guessing from your code that it’d be this p_area that you should be deleting.
You’ll probably have an easier time if you move the code for hit detection from the player to the peg. That way you don’t have to bother with grabbing references to pegs like wchc advised.
To do that you just put a script like this in the peg’s root node, and connect the signal from the peg’s area 2D to the root node’s script via the signals menu:
This way the pegs handle their own deletion. If you’re deleting lots of pegs at the same time, call_deferred(“self.queue_free()”)can be substituted to prevent errors and lag.