NaN when trying to assign a value to an attribute

EatMoreHippo

  • Posts: 62
This NaN error always seems to come up when I try to set an attribute to a value and then set that value to the attribute (so I can save the dynamic number and use it again after setting the dynamic number to a temporary number).

How can I make this work without producing the Not a Number error?

Silux

  • Posts: 438
Attribute must be set under the 'When created' block otherwise the game will work with a missing number(and he hates it).

Screenshot the entire behaviour please!
Currently working at:
Starwarrior 2097(my main project)
How to make successful games in Kongregate and the world(article)

herby

  • Posts: 124
This NaN error always seems to come up when I try to set an attribute to a value and then set that value to the attribute (so I can save the dynamic number and use it again after setting the dynamic number to a temporary number).

How can I make this work without producing the Not a Number error?

First rule of good programming: Don't Repeat Yourself (known as DRY principle). In this case it means, do not use "otherwise if <repeated-condition-of-previous-if-just-negated>", use only "otherwise".

Second, Silux pointed to the right thing: your attributes (even if they are Number) are not initialized, you should give them some meaningful value in when created block.