Folder is not saving

Hello everyone! i am working on a data store for my shop. So i am trying to save a folder in my datastore. So im adding string value when a player click on “buy” button but how can i exactly save those values?

--leaderstats / loading player's data

local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("dataman")



game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder")
	stats.Name ="leaderstats"
	stats.Parent = player
	
	
	local Strength = Instance.new("NumberValue")
	Strength.Name ="Strength"
	Strength.Parent = stats
	
	
	local Coins = Instance.new("NumberValue")
	Coins.Name ="Coins"
	Coins.Parent = stats

	
	local gems = Instance.new("NumberValue", stats)
	gems.Name = "Gems"

	
	local storage = Instance.new("StringValue")
	storage.Value = "10"
	storage.Name = "Storage"
	storage.Parent = player
	
	local EquippedCl= Instance.new("StringValue")
	EquippedCl.Name = "Class"
	EquippedCl.Parent = player
	EquippedCl.Parent = stats
	EquippedCl.Value = "Rookie"
	
	
	local EquippedCl2= Instance.new("StringValue")
	EquippedCl2.Name = "EquippedCl"
	EquippedCl2.Parent = player
	EquippedCl2.Value = "Rookie"
	
	local Multi= Instance.new("StringValue")
	Multi.Name = "Multi"
	Multi.Parent = player
	Multi.Value = 1
	
	
	local Ownedtools = Instance.new("Folder")
	Ownedtools.Parent = player
	Ownedtools.Name = "Ownedtools"
	
	local firsttool = Instance.new("StringValue")
	firsttool.Parent = Ownedtools
	

	
	
	
	local Ownedcl= Instance.new("Folder")
	Ownedcl.Parent = player
	Ownedcl.Name = "Ownedcl"
	
	local rookie = Instance.new("StringValue")
	rookie.Parent = Ownedcl
	rookie.Name = "Rookie"
	
	local Equippedst = Instance.new("StringValue")
	Equippedst.Parent = player
	Equippedst.Name = "Equippedst"
	Equippedst.Value = "Default"

	local Ownedst = Instance.new("Folder")
	Ownedst.Parent = player
	Ownedst.Name = "Ownedst"
	
	local default = Instance.new("StringValue")
	default.Parent = Ownedst
	default.Name = "Default"
	
	local Equipped = Instance.new("StringValue")
	Equipped.Parent = player
	Equipped.Name = "Equipped"
	
	local Canautohatch = Instance.new("BoolValue")
	Canautohatch.Parent = player
	Canautohatch.Name = "Canautohatch"
	Canautohatch.Value = false	
	
	local multistrength = Instance.new("StringValue")
	multistrength.Parent = player
	multistrength.Name = "multistrength"
	multistrength.Value = 1
	
	
	local id = "player_"..player.UserId
	local data

	local success , err = pcall(function()
		data = ds:GetAsync(player.UserId)

	end)

	
	
	
	if success and data then
		Coins.Value = data[2]
		Strength.Value = data[1]
		gems.Value = data[3]
		storage.Value = data[4]
		Equippedst.Value = data[5]
		
		for _, storageName in pairs(Ownedst:GetChildren()) do
			local val = Instance.new("StringValue" )
			val.Name = storageName.Name
			val.Parent = Ownedst
		
		end
		
		for i,v in pairs(player.Ownedtools:GetChildren()) do
			local str = Instance.new("StringValue" , player.Ownedtools)
			str.Name = v.Name
		end


	else
		print("the player has no data")
		
		
	end
	
end)



--saving players data

local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("dataman")


local function savedata(plr)
	local tabletsave = {
		plr.leaderstats.Strength.Value,
		plr.leaderstats.Coins.Value,
		plr.leaderstats.Gems.Value,
		plr.Storage.Value,
		plr.Equippedst.Value
	
		
	}
	local Owendstorage = {}
	local Owendtools = {}
	
	local success, err = pcall(function()
		ds:SetAsync(plr.UserId, tabletsave )
		local tables =  {}

		for i,v in pairs(plr.Ownedst:GetChildren()) do
			local update = table.insert(tables,v.Name)
			print(update)
		end

		ds:SetAsync(plr.UserId,tables)
		
	end)
		if success then
			print("Good job")
		else
			print("Data no save")
			warn(err)
		end
	
end

game.Players.PlayerRemoving:Connect(function(plr)
	
	
	savedata(plr)
	
	
	
end)

game:BindToClose(function()
	for _, plr in pairs(game.Players:GetPlayers()) do
		savedata(plr)
		
	end
end)


Could you create a table by looping through the folder and then save it?

Yes, infact i tried that multiple times but the problem is it only saves one stringValue

now i got to save one string but i still cant save the folder. Please

fixed it by loooping the table during bindtoclose and well as playerremoving