+2 votes

I keep getting the above error when i try to call this function:

func gain_exp(amount):
    cur_exp += int(amount)
    total_exp += int(amount)

If it helps, I'm declaring and assigning the variables like this:

var total_exp
var cur_exp

func _ready():
    cur_exp = 0
asked Jun 22, 2018 in Engine by ShingleBells (18 points)

1 Answer

+2 votes

you only declare variable, not set value.
so, var total_exp is same as var total_exp = null

you can simply fix it by assigning default value.

var total_exp = 0
var cur_exp = 0
answered Jun 22, 2018 by volzhs (9,483 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.