How do I get webstorage to save?

0 favourites
  • 6 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • ok so just trying to get a simple highscore functioning, and it does but every time i close the game the highscore resets to zero or if i dont score i get NaN

    on the first layout (in reference to highscores) i have:

    global highscore = 0

    on start -

    local key "HighScore" exists - set highscore to WebStorage.LocalValue("HighScore")

    else - set local key WebStorage.LocalValue("HighScore") to 0

    on the game over layout (in reference to highscores) i have:

    score > WebStorage.LocalValue("HighScore") - set WebStorage.LocalValue("HighScore") to score

    ------------------------------------------------set highscore to score

    ------------------------------------------------set text to "Highscore" & highscore

    score < or equal to highscore - set text to "Highscore" & highscore

    just as a note when i change the "set text to "HighScore" & highscore to score"

    to

    "set text to "HighScore" & WebStorage.LocalValue("HighScore") to score"

    the output is just HighScore

  • From what i know WebStorage values are kept in strings, so try int(WebStorage.LocalValue("HighScore"))

  • that didnt fix it :/ i ran it in debug mode and when i look at the webstorage that the value for "HighScore" doesnt have a name, only a value.

  • Go through this tutorial.

    Read the manual. To see how to compare text/number.

  • "set local key WebStorage.LocalValue("HighScore") to 0"

    I think the problem is here, you don t want to set the local key named WebStorage.LocalValue("HighScore") but the one named "HighScore".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much guys, Aphrodite u found the problem.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)