Problem with coding collectable

Godot Version 4.4

Question: I am trying to code in a collectable gem and cant seem to get it to work i don’t know why here is my code i am very new to Godot:

extends Node2D

func _ready():
add_to_group(“Gem”)

func _on_body_entered(body: Node2D) → void:
if is_in_group(“Gem”):
self.queue_free()

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta: float) → void:
pass

Please format your code when uploading it to the forum: Make it easier for new users to format and preview code in their posts - #4 by gertkeno

This won’t fix the issue, but it would be a good idea that it’s the player that entered the area before destroying the gem, otherwise any physics body will work.

Have you connected the signal body_entered to the function _on_body_entered() from your script? (For this to work, the script needs to be on an Area2D. If that’s already the case, putting extends Area2D instead of extends Node2D would make that clearer)