My code doesn't create a table entry for the things I want it to insert

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve that the following code creates a table for a DataStore with the values from a folder.

  2. What is the issue? Include screenshots / videos if possible!
    Despite there being multiple things inside the Folder where I’m trying to get the values from, there is only one thing from the folder inserted into the table I want it to be in.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried two different ways of putting it into the table, but neither of them puts all of the things from the folder inside the table. I haven’t found anything specific to my problem on the forum.

This is how the source looks like

  21:51:08.592   ▼  {
                    ["Data1"] =  ▶ {...},
                    ["Equipped"] = {},
                    ["Inventory"] =  ▼  {
                       ["Effects"] =  ▼  {
                          [1] = "Value"
                       ["Tools"] =  ▼  {
                          [1] = "Test"
                    ["leaderstats"] =  ▶ {...}
                 }  -  Server

Above is the table that is printed in the output. And how you can see there is only one value for Effects and Tools, but it should be more as indicated in the picture from the explorer.

Below is the code responsible for what I’m trying to achieve.

	local data = {}
	for _, folder in game.ReplicatedStorage.PlayerData:GetChildren() do
		local subData = {}
		for _, child in player[folder.Name]:GetChildren() do
			if child:IsA("Folder") then
				for _, category in child:GetChildren() do
					subData[child.Name] = {category.Name}
					for index, thing in category:GetChildren() do
						--subData[child.Name][category.Name][index] = thing.Value
						table.insert(subData[child.Name][category.Name][index], thing.Value)
				subData[child.Name] = child.Value
		data[folder.Name] = subData