You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I need to save a folder of values. -
What is the issue? Include screenshots / videos if possible!
I cannot figure out how to save a dictionary, I have tried everything on the dev forum but I just dont understand it. I am using a folder to dictionary function and saving it on bind to close but all values just stay set to true (each value is a boolean) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried lots of different solutions but none of them work properly for me.
Here is my current code, right now it is setting every single value to true.
local function folderToDictionary(folder)
local dictionary = {}
for _, object in ipairs(folder:GetChildren()) do
if object:IsA("Folder") then
dictionary[object.Name] = folderToDictionary(object)
elseif object:IsA("ValueBase") or object.ClassName:match("Value") or object:IsA("Trail") then
if object:IsA("ValueBase") or object.ClassName:match("Value") then
dictionary[object.Name] = object.Value
elseif object:IsA("Trail") then
dictionary[object.Name] = false
end
end
end
return dictionary
end
local undefinedtStore = DataStore2("undefinedt", player)
local undefinedvals = undefinedtStore:Get(false)
for i2,v2 in pairs(game.ReplicatedStorage.Trails:GetChildren()) do
if not trailinventory:FindFirstChild(v2.Name) then
local trailnew = Instance.new("BoolValue")
trailnew.Name = v2.Name
trailnew.Value = undefinedtStore:Get(false)
trailnew.Parent = trailinventory
end
end
game:BindToClose(function()
local undefinedtrails = folderToDictionary(trailinventory)
undefinedtStore:Set(undefinedtrails)
end)
Please respond with answers for Datastore2, not roblox’s default Datastore (I know datastore2 uses roblox’s default datastore)