How to use localStorage?

I am creating a script where the player can save and load his game progress. The data should be stored in the local storage. In the script is the code for creating two buttons on the game screen labeled “save”, and “load”. the buttons should work to where when clicked, they can save the players data, and load it. How would I finnish this?
Here is the script:
the codes:

ps, the data such as the player’s level, and the items in his inventory will be stored in variables, such as:

var ItemInInventorySlot1 = ‘no item’;

I guess u can use cookies but don’t know how…sorry

localStorage is quick and easy way to go.
Online docs can help you with that:

You haven’t asked what a problem specifically you experience, what have you tried and what didn’t worked?
It is always best to try, learn and move slowly but steadily towards your target. MDN I found one of the best JavaScript general purpose websites with loads of examples, documentation, and general knowledge on JS.

thanks, now when the game is loaded, how are the variables sopposed to be set to what was saved?

Please, show what you have tried to do, in order to achieve what you are intended to? So that we can see what problems you experience, and can assist you in solving them.

I’m not sure people will be able to write your code for your ideas, that is your “homework” to do :smile:

Use tutorials: to learn basics and then progress slowly, so you will then have idea how to tackle your ideas.

When you initialize your script you can read the values from localStorage and set them to your internal script variables.

So if you had previously saved a value called ‘myVar’ in localStorage you can read it back like so

var myVar = localStorage['myVar'];

Does that help?