Trying to save an array to DataStore and how to access it

I found a solution to my problem. Although its not exactly what I wanted it to, it does the job.

Instead of saving it in an array i used a dictionary. The code is:

		local Dict = ServerData[Player]
		
		for _, v in ipairs(Player.UnlockIds:GetChildren()) do
			Dict["UnlockIds"][v.Value] = v.Value
		end

I did use a different way of working with the data. Basically every time a player joins i get their data and add it to the dictionary ‘ServerData’. Which is also why I index it by ‘Player’.

Then I call the UnlockIds dictionary INSIDE the ServerData[Player] dictionary and loop it with the code above that basically adds a new Key and Value for each child in my UnlockId folder.

Dont know if this is a ‘good’ way to do it, but it works and it doesnt seem to break anything.

2 Likes