Hello, I've been working on my Datastores script for a while now but there's one last part I haven't been able to do yet. That's basically getting the children of the folder I'm holding all the values to save and saving them. The reason I want to do this is because there's going to be a lot of possible stuff to get in the game however I don't want the player to start w/ that stuff. For example, I'm making a system where rare items will spawn randomly and if a player touches it they'll get it. Anyways, this is what I have so far, but it doesn't work.
local items = {} for i,values in pairs(player.Data:GetChildren()) do table.insert(items,i,values) end DataStore:SetAsync(key, items)
Not quite sure what's going wrong but any help is appreciated!
The problem is that you are trying to store the object value e.g. the stats object not the value they contain.
local items = {} for i,values in pairs(player.Data:GetChildren()) do table.insert(items,i,values.Value) -- you need the value end DataStore:SetAsync(key, items)
I would suggest that you save them as key value pairs
local items = {} for i,values in pairs(player.Data:GetChildren()) do items[tostring(values.Name)] = tostring(values.Value) -- make a key value pair end DataStore:SetAsync(key, items)
Hope this helps.