So basically, I want to save some Values that firstly do NOT exist and all have different Names.
The Instance that gets Created is this one:
for _, v in pairs(game.Workspace.Gate_System.Gates:GetChildren()) do
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue", leaderstats)
Coins.Name = "Coins" -- Rename to what ever the Coins Stats should be called
Coins.Value = 100
local GateFolder = Instance.new("Folder", player)
GateFolder.Name = "GateFolder"
local GateValue = Instance.new("BoolValue", player:WaitForChild("GateFolder"))
GateValue.Name = v.Config:WaitForChild("NameGate").Value
GateValue.Value = false
end
The pairs statement is just there to define all pats and get the name from a value. my concept of this issue would be to do this:
-- for loading:
local success, err = pcall(function()
GateValue.Value = ds:GetAsync(player.UserId)
end)
-- for saving
local success, err = pcall(function()
for _, v in pairs(game.Workspace.Gate_System.Gates:GetChildren()) do
local GateValue = player:WaitForChild("GateFolder"):WaitForChild(v.Config.NameGate.Value)
ds:SetAsync(player.UserId, GateValue.Value)
end
end)
this doesn’t work tho so what can i do to make this work? (i am fairly new to scripting and i am trying to save gates)