Hey, if i had a regular script that saved values, how would i make it save all descendants of a folder thats a bool value and all have the the name “IfEquipped”. I would guess that i would use v in pairs but i would know how to add that to the datastore script.
1 Like
Hi, You are certainly on the right track. What I would do is store all bool values in a table, and use the table as the new value for the datastore.
local folder -- folder containing bool values
local dsService = game:GetService("DataStoreService")
local dataStore = dsService:GetDataStore("global")
local data = {} --stores all bool values
for i, v in pairs(folder:GetChildren())
if v:IsA("BoolValue") then
if v.Name == "IfEquipped" then
table.insert(data, v.Value) -- insert bool to the "data" table
end
end
end
dataStore:UpdateAsync("key_userId", function(oldValue)
local newValue = data or oldValue
return newValue -- send bool table to data store
end)
1 Like
Ok, thats nice, so what would i do if the folder is in a players gui
1 Like
I guess saying how would i add that to the script that has the player removijgnand adding in the datastore script
1 Like