load ajax last data. I changed it to load from localStorage.itemvalue
Sorry, of course it should be localStorage.itemvalue
LocalStorage events are asynchronous, meaning that you need to wait for them to finish. The last event on your screenshot doesn't wait and sets player's health to the default value from the dictionary (while the data from LS is still loading). I suggest you change it to a function: