How to fix this error: Invalid operands 'Nil' and 'int' in operator '+'.?

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

:bust_in_silhouette: Reply From: timothybrentwood

Your score variable is not defined in that function’s scope. Make sure your score variable is defined outside of any function:

var score = 0

func _ready():
    score += 1 # works!

I have other error…

David8184 | 2021-07-11 22:27

In the script attached to your HUD node (HUD.gd by the looks of it) you need to create a function called updatescore e.g. :

func updatescore(new_score):
    pass # erase pass and make it do something

timothybrentwood | 2021-07-11 22:47