Hi everyone! I desperately need your help. I have a scene like this:
-- Coin (Area2D)
My problem is to add a label that scores the points when the player collects the coin. I tried in every way, looking also in this section, but there is nothing to do! I just can’t start the score!
In a previous answer, someone told me to add this script:
var score = 0 #hold the score
func addScore(val): # function to add the score
score += val # add val to score
$Label.set_text(score) # Set the text of label to score
func onArea2Dareaentered(): # when something enters area2D
addScore(1) # add 1 to score
I tried to insert the function in the Score script, and addScore () first in the coin script, then in the Main script, but nothing happens. In which scripts should I enter the code?
Anybody could help me, please? :-(