Hey! I'm having trouble with something regarding Data Stores, I know how they work and everything(although confusing sometimes). However, i need to store a large amount of data quickly and easily in a way where i don't have to really change the storage script if i change anything in the values or add any values. I have attempted using tables, and although i am more knowledgeable with tables and arrays, i cant seem to figure this one out. Does anyone have any thoughts of how to store a whole folder worth of data? There is another folder full of values inside the main folder, and those values also have children regarding those values. Thanks! -Manelin
local DSService = game:GetService('DataStoreService'):GetDataStore('MagicalnessTesting') --Change this name to a random name or it will not work
local Variables = {}
game.Players.PlayerAdded:connect(function(plr)
-- Define variables
local uniquekey = 'id-'..plr.userId
local MagicValues = game.ServerStorage:FindFirstChild("MagicValues"):Clone()
MagicValues.Parent = plr
print("Put MagicValues in player", plr.MagicValues)
local MagicSpells = MagicValues.Spells
wait(2)
for _, Values in pairs(MagicValues:GetDescendants()) do
if Values:IsA'StringValue' or Values:IsA'NumberValue' or Values:IsA'BoolValue'then
table.insert(Variables, Values.Name)
Variables[Values.Name] = tostring(Values.Value)
print(Variables[Values.Name].."Vairables")
end
end
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
for i = 1, #Variables do
Variables[i].Name = GetSaved[Variables]
end
else
for i = 1, #Variables do
DSService:SetAsync(uniquekey, Variables)
end
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local MagicValues = plr.MagicValues
local Savetable = {}
for _, Values in pairs(MagicValues:GetDescendants()) do
if Values:IsA'StringValue' or Values:IsA'NumberValue' or Values:IsA'BoolValue'then
table.insert(Savetable, Values.Name)
Savetable[Values.Name] = tostring(Values.Value)
DSService:SetAsync(uniquekey, Savetable)
end
end
end)

2 comments
Yes, you can store a table of data inside one single DataStore! I'll type something out for you to help.
"manor"