# How do I fix this NaN high score error?

Just started using Construct 2? Post your questions here

### » Thu May 08, 2014 5:34 am

I cant fix my high score NaN error.
Untitled.png

The Events

Untitled2.png

Before Playing a Round

Untitled3.png

After Playing A Round
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 16
Reputation: 282

### » Thu May 08, 2014 5:50 am

NAN means Not A Number. Somewhere in your logic you are getting something assigned to your variable that is not counting as a number. Either that or you may need to round as certain things tend to create a lot of decimal (floating point) places in your numbers.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Thu May 08, 2014 5:57 am

None of my variables for the points, which is what is counted, use decimals, they are all whole numbers. Everyhting that would contribute to the score is in the Scoring group
B
6
Posts: 16
Reputation: 282

### » Thu May 08, 2014 6:04 am

Is there any chance that Base.Health may equal 0? If so then you are dividing by zero which would also cause the NaN error...
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Thu May 08, 2014 6:05 am

Also I notice that you are setting highscore both every second and on every tick. You should do one or the other. The every second would be better unless you need it sooner in which case you can do every 0.5 seconds.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Thu May 08, 2014 6:07 am

I removed that right after I took this picture, it did not help. I set it to every 0.5 seconds.
B
6
Posts: 16
Reputation: 282

### » Thu May 08, 2014 6:09 am

It does equal zero at one point, but nothing is ever divided by it or another 0.
B
6
Posts: 16
Reputation: 282

### » Thu May 08, 2014 6:12 am

Sure it does, right there in your events it shows base.Health/100... if base.Health happens to be 0 at that point then you are dividing by 0...
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633

### » Thu May 08, 2014 6:14 am

It is [100*(base.Health/100)] which would be 100*(0/100) or 0
B
6
Posts: 16
Reputation: 282

### » Thu May 08, 2014 6:20 am

The other piece throwing me off is the finaldata.finaldata are you having an instance variable that has the same name as the object? Gah, just realized what time it is, time for me to hit the rack.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,633