Dodge the Creeps- "The identifier 'score' isn't declared in the current scope." / Hit Signal

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By earphones

I am following along with the ‘Your first 2d Game’ guide.

Stuck spot

Following these steps I end up with the code

func game_over():
    $ScoreTimer.stop()
    $MobTimer.stop()

func new_game():
    score = 0
    $Player.start($StartPosition.position)
    $StartTimer.start()

in the Player.gd. I understand that the error is saying that score isn’t in Player.gd, but what am I doing wrong in the first place?

Node tree

:bust_in_silhouette: Reply From: jgodfrey

I’m not overly familiar with the written tutorial, but checking the official Github repo for that sample project, I can see the code you mention belongs in Main.gd, not Player.gd.

Perhaps that’ll get you going again?

Thank you for your reply, I did notice that when I was referencing it this morning while rewriting. Placing the code the Main.gd results in a blank game screen unfortunately.

earphones | 2022-08-09 22:34

:bust_in_silhouette: Reply From: earphones

NAB, re-reading the instructions I see I missed a critical 2nd step.

What was the 2nd step?

bananaVelocity | 2022-08-24 22:39