By putting a 0.1 second wait before the local storage gets the key , it worked . But what i am actually trying to do is more complicated .
I am creating an RPG where a player can have up to 5 characters , and all of the data of these characters are saved to the local storage .
If you delete a character , the entire local storage keys should change . For ex :
If you have 3 characters and you delete your first one , your old second character will now be the first one , and your old third character will now be the second one .
The data that will change includes all the inventory slots of the characters .
So , in the example cited before , the now first character would have all of the data of the inventory slots of the old second character , and the now second character would have all of the data of the inventory slots of the old third character .
To do this , i am doing a loop that repeats 24 times ( amount of inventory slots ) , but it's not working . The keys are not changing at all .
PS : All the keys are already saved , so all the keys that are being get from the event already exist .
Here are 2 prints ( these represent all the data that needs to be changed if the player just deleted his first character ) :
I don't expect anyone to come up with a solution immediately , since this is really hard for me to explain and also for someone not involved in the project to understand .