Saving a highscore?

I need help saving a high score. I know I need to use something like the saveLocalData function, but I have no idea how. How would I make it save my highscore when the program or app is closed or restarted?
I have something like this to set the highscore, I want to save the variable highScore, but not currentLevel.

if highScore < currentLevel then
    highScore = currentLevel
--And here I want to save the highscore so it wouldn't get deleted, how would I do that?
end
if highScore < currentLevel then
highScore = currentLevel
saveLocalData("HighScore",currentLevel)

I believe you already had a thread about this…

Oh yeah you’re right I did. thank you :slight_smile:

@CodeaNoob do I still need to save highscore as a variable?

This is what I do for initial setups for Highscores;
Note: Score is just what I use, currentLevel would take its place for you

function setup()
if readLocalData("HS") == nil then
saveLocalData("HS",0)
end

When the game is over:

if Score > readLocalData("HS") then
saveLocalData("HS",Score)
end

Thank you @CodeaNoob x)
So how would i make that variable appear on the screen?

Nevermind , got it! Thank you @CodeaNoob :slight_smile: