# How do I fix this NaN high score error?

0 favourites
• 10 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
• I cant fix my high score NaN error.

[attachment=2:gkk0k4ak][/attachment:gkk0k4ak]

The Events

[attachment=1:gkk0k4ak][/attachment:gkk0k4ak]

Before Playing a Round

[attachment=0:gkk0k4ak][/attachment:gkk0k4ak]

After Playing A Round

• 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.

• 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

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• 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...

• 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.

• I removed that right after I took this picture, it did not help. I set it to every 0.5 seconds.

• It does equal zero at one point, but nothing is ever divided by it or another 0.

• 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...

• It is [100*(base.Health/100)] which would be 100*(0/100) or 0

• 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.

• 10 posts