I have a dictionary that is created like this which is given default values with newly joining players and will also be saved with any changes to it like this. (dictlist just looks like an empty table)
dictlist[player.Name] = { Coins = 10, Pts = 0, StringLetter = "J" }
dictload is just dictlist being saved when the player leaves as a separate dictionary
for i, v in pairs(dictload) do --print(statstosave[plr.Name][tostring(v)].." = "..v) if dictlist[plr.Name][v] then dictlist[plr.Name][v] = v print("data exists") end end
Data saves the dictlist also by replicating this dictionary (as any changes to it will occur and it will replicate those changes) but it never loads because dictlist[plr.Name][v]
does not exist (nil
) .
For example in the loop, I would like to index ["Coins"] but with the for pairs loop, using either v
or tostring(v)
returns only nil yet the loaded dict (print checked) actually has ["Coins"] in it with a given value.
I am assuming that I am not correctly indexing the other dictionary's values although the dictionary has the equivalent variables using this method, I am asking for an answer that solves this problem.
Solution: Copy loaded dictionary via a different way/replace dictionary with loaded dictionary (used replacement, I just set it as the loaded dictionary)