Yes, I did use a simulator tutorial script because I'm not good at services.
I'm trying to save a huge chunk of values and I used :GetChildren() and it doesn't work.
I'm trying to find an alternative way to save tons of values without putting tons of functions.
Here is the script:
local DS = game:GetService("DataStoreService"):GetDataStore("StatData") game.Players.PlayerAdded:Connect(function(plr) wait() local plrkey = "id_"..plr.userId local savevalue = plr.leaderstats.Coins local savevalue2 = plr.leaderstats.Gems local savevalue3 = plr.leaderstats.Power local savevalue4 = plr.Stats.ElementInv:GetChildren() local savevalue5 = plr.Stats.PetInv:GetChildren() local GetSaved = DS:GetAsync(plrkey) if GetSaved then for e = 1,#savevalue4 do for a = 1,#savevalue5 do local save4 = savevalue4[e] local save5 = savevalue5[a] savevalue.Value = GetSaved[1] savevalue2.Value = GetSaved[2] savevalue3.Value = GetSaved[3] save4.Value = GetSaved[4] save5.Value = GetSaved[5] end end else for e = 1,#savevalue4 do for a = 1,#savevalue5 do local save4 = savevalue4[e] local save5 = savevalue5[a] local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value, save4.Value, save5.Value} DS:GetAsync(plrkey, NumbersForSaving) end end end end) game.Players.PlayerRemoving:Connect(function(plr) local savevalue = plr.leaderstats.Coins local savevalue2 = plr.leaderstats.Gems local savevalue3 = plr.leaderstats.Power local savevalue4 = plr.Stats.ElementInv:GetChildren() local savevalue5 = plr.Stats.PetInv:GetChildren() for e = 1,#savevalue4 do for a = 1,#savevalue5 do local save4 = savevalue4[e] local save5 = savevalue5[a] DS:SetAsync("id_"..plr.userId, {savevalue.Value, savevalue2.Value, savevalue3.Value, save4.Value, save5.Value}) end end end)
-- Saving local SaveTable = {} for i, v in pairs(plr.leaderstats:GetChildren()) do table.insert(SaveTable,{v.Name..v.Value}) end -- Loading for i, v in pairs(DS:GetAsync("id"..plr.userId)) do if plr.leaderstats:FindFirstChild(v[1]) ~= nil then plr.leaderstats[v[1]].Value = v[2] end end
Might work im not sure, if it doesn't it kinda gives an idea on how to do it