What is this script attached to, the player?
So the player listens to the coin signaling something entered its shape, and then the player deletes the coin?
Why not have the coin delete itself when something enters its shape?
Why do you use the area_shape_entered signal? I personally never used that one, area_entered and body_entered seem more useful.
By the way, what is the coin supposed to collide with, an area or a (collision) shape? Maybe you are connected to the wrong signal.
Finally to your last question: if this is the player’s script, the second line assumes the player has a child node named Coin. It’s not necesserily wrong, but the relationship is weird. If it’s a child node, it denotes that the player owns the coin, while in this case I assume you want the player and coin be separate objects in your world right?
As I know that when i duplicate coin node (ctrl+d) it gets from
“coin”
to:
“coin2”
Thats why I think this code works for me good for players ($Player) root script that can be called from “World.gd” or as you had called it as Node2D script:
for index in $Player.get_slide_count():
var collission = $Player.get_slide_collision(index)
if collission.collider.name.begins_with("coin"):
get_node(collission.collider.name).queue_free()