Can not read a file

Hi. I have just started working on a game for the first time. I am pretty close to finishing it. The problem I’m facing is that I can not save and load highscore of mmy game. I am trying to get help from this previous post of Rob Miracle https://coronalabs.com/blog/2013/12/10/tutorial-howtosavescores/ . here is what I have done:

I made a NEW ASSET and pasteed the MODULE CODE in it. Then I pasted the last bit of code in the main.lua to get the score. then I’m using this

 local highscore = score.load()

highScoreText.text = highscore

to display my score. but when I run the code, it says it cannot read the file ‘scorefile’ and return a nil value.

What am I doing wrong here? I think I have not put the scorefile.txt in the correct place. Can you guide where I should save it?

Thanks

You have to save the file first. There should be an API to save the score. 

Rob

There is also the possibility that the file is empty. You would have to check if this is the case.

if highscore == nil then --make highscore = 0 else --show saved highscore end

You have to save the file first. There should be an API to save the score. 

Rob

There is also the possibility that the file is empty. You would have to check if this is the case.

if highscore == nil then --make highscore = 0 else --show saved highscore end