[SOLVED] Local Storage Variables Randomly Reseting

I’m working on a skin system in my game the skins themselves work and the other players can see the skins but I’m saving whether or not a skin is unlocked in a local storage variable witch keeps randomly reseting itself and it resets when the page is reloaded.

I’m very confused it mainly resets when it gets read and when another local storage item gets set

Here is the link to the 4 scripts causing the issue
https://playcanvas.com/editor/code/719734?tabs=53943724,53977606,53958036,53975697

Hey @WilliamBoersma31,

By taking a quick look at your scripts, you seem to be clearing and then changing the value using localStorage.set. Normally, you wouldn’t need to do that, you can just use set to change the value from true to false, so is there any specific reason as to why you are clearing it every time before setting the value?

1 Like

There was but it’s no longer needed 1 sec I’ll try with out it

It seems to have fixed the part where it resets when a new one is added but it still resets when called

Can you please let me know which script is fixed and which one is still faulty? In ChooseSkin.js I saw that you are still clearing and then setting the localStorage, so I assume there is a special reason for that particular script?

1 Like

Thanks @DevilZ I didn’t even notice that but I fixed it and now it works great

1 Like