How can I save a Folder with Values that get Created when a new part has been created?

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)

I would recommend using DataStore2 and Roblox’s datastore doesn’t have a backup system for unexpected crashing, and you can only save values that exist.

ah okay, but this wouldn’t have answered my question on how to save data that is going to be created when another gate is added to the folder.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.