Coin detection continuesafter collected

I’m doing a 2D plataformer wher you collect coins after touching them
This is my script for it:

func _on_area_2d_body_entered(body):
if body.get_name() == “Player”:
global.coin += 1
set_visible(false)
get_node(“main/Area2D”).monitoring = false

The problem with it is that after I collect the coin the area where it was collected will still keep increasing the variable. How can I disable the area 2D node for this to properly work?

get the area and do something like this

var node = get_node("main/Area2D")
node.queue_free()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.