error details

what does "attempt to compare nil with number means " ?
I am getting this error when i try to compare my game score to best score.Please help me know what to do with that error… [import]uid: 82446 topic_id: 18022 reply_id: 318022[/import]

Nil means it doesn’t exist.

Are you still using the same score system as previously? If so you should make sure you are using score.getScore() (I believe that’s it, if not, check the score file as it is listed there) to compare.

Peach :slight_smile: [import]uid: 52491 topic_id: 18022 reply_id: 68863[/import]

No.I am not using the one that i had asked you for.Now i am doing it in a different way.I am taking four variables
[lua] local gameScore = 0
local bestScore
local scoreText
local bestScoreText[/lua]
gameScore is used at the time of playing game
bestScore as the name depicts
scoreText is used for displaying the gameScore
bestScoreText for displaying the bestScore
So when the game is over i am calling the following function

[lua] local function gameover()
if gameScore > bestScore then
bestScore = gameScore
local bestScoreFilename = restartModule … “.data”
saveValue( bestScoreFilename, tostring(bestScore) )
end[/lua]
now I am getting an error in the if statement.
Hope u understood what i wanted to say.Please help me … [import]uid: 82446 topic_id: 18022 reply_id: 68887[/import]

Are you using director? If so, your local gameScore wont be available in other scenes. (Because it is local not global.)

If not, have you defined bestScore as a number value before trying to compare the two values?

Clearly one is being seen and the other is not - that’s what we need to work out now.

Peach :slight_smile: [import]uid: 52491 topic_id: 18022 reply_id: 68905[/import]