Value appearing as "NaN".

0 favourites
  • 5 posts
  • I'm trying to set a global variable to save via "LocalStronge", so it keeps the value even after you exit and re-open the game. I thought I finally got it working, but when the layout loads, the value appears as as "NaN". I've seen that this means "Not a Number". I'm not sure how to fix this and it's really worrying. It's the last hurdle to finishing my game.

    For clarification, the global variable in question I'm trying to save is number, like as in displaying the number of coins you have etc.

    If anyone know how to fix this I'd be really grateful.

    Thanks in advance.

  • You are doing something wrong. You need to post your project file or a screenshot of your events.

    Or check how to use Local Storage in the official template.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are doing something wrong. You need to post your project file or a screenshot of your events.

    Or check how to use Local Storage in the official template.

    Thanks very much. Here's an image of the inputs. I added a link in case the screenshot doesn't upload properly.

    imgur.com/a/6F6586M

  • In the last line on your screenshot you are saving "Coins" string, instead of Coins variable. That's why it's NaN, because the string can't be converted to a number.

    You need to remove the quotation marks.

  • In the last line on your screenshot you are saving "Coins" string, instead of Coins variable. That's why it's NaN, because the string can't be converted to a number.

    You need to remove the quotation marks.

    Oh my gosh, it worked! Thank you so much! I can finally finish my game! I'm so happy. I'm going to put you in the credits if that's okay! Such a tiny mistake. :)

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