Is there a way I can use a datastore to save what is in a folder? If there is please let me know.
Thanks!
Yes, however you can’t directly save the instances inside the folder. You can only datastore things like Strings, Booleans, Numbers, etc. No Roblox class types. This is still possible, as you could loop through the children of the folder and save those objects. For example, if you had a folder full of IntValues you could save them like this:
local dictionaryToSaveTo = {}
local folder = game.ReplicatedStorage.Folder
for index, value in ipairs(folder:GetChildren()) do
dictionaryToSaveTo[value.Name] = value.Value
end
print(dictionaryToSaveTo)
This would print a dictionary containing whatever values you have in that folder. So you’d have to encode it like this manually. Then, when loading the datastore you’d have to decode it manually. I think JSONEncode might work for this, however I’m not familiar with that, and sometimes I prefer to save it in my own format.
2 Likes
for i,v in pairs(plr.Data:GetChildren()) do
table.insert(v.Value, table)
end
data:SetAync(plr.UserId, table)
3 Likes
Well i will just save them in int values.
Thanks for you explanation.
1 Like