Hello.
My name is Fred. I am working on a small 2d game about collecting stuff. I got some basic coding skills but I am not that good at it and find myself getting stuck from time to time.
The problem:
Player is gonna collect chanterelles. This by pushing a button, in my dualshock4 controller square button, or the key X. I got a simple HUD setup with a Singleton which displays a chanterelle and a number, start from 0. When collecting a chanterelle, it should add 1.

So if I hold the controller square button down, it adds more than 1 to chanterelles.

It adds more than 1 chanterelles when using controller button. Not all the time but still. Any suggestions how to solve this?
/Fred
EDIT: solved, I got some help on the Godot discord.
Just added canBeCollected = false after the Input check and before the playerCollected.chanterelles += 1
code:
extends Area2D
var canBeCollected: = false
onready var animatedSprite: = $AnimatedSprite
onready var playerCollected: = $"/root/PlayerCollectedVariables"
func _ready() -> void:
animatedSprite.play("default")
func _input(event: InputEvent) -> void:
if canBeCollected && Input.is_action_just_pressed("interact"):
animatedSprite.play("collected")
z_index = 100
playerCollected.chanterelles += 1
print("chanterelle collected!")
print(playerCollected.chanterelles)
func _on_Chanterelle_big_1_area_entered(area: Area2D) -> void:
print("player detected!")
canBeCollected = true
func _on_Chanterelle_big_1_area_exited(area: Area2D) -> void:
print("player exited!")
canBeCollected = false
func _on_AnimatedSprite_animation_finished() -> void:
if animatedSprite.animation == "collected":
queue_free()
print("queue_freed!")