So what I'm trying to do is get a table to save in a data store. But in order to do that, I must save X amount of values in the table AND THEN save that table in the data store, but for some reason the table has 0 items in it. Here's the script: (P.S. I skimmed the script to the most important parts. Every variable has a value and everything is double checked to work right; The only problem seems to be that the children don't get added to the table so I'm not sure what's wrong with it.)
local inventoryToSave = {}
for _,category in pairs(inventory:GetChildren()) do
for _,item in pairs(category:GetChildren()) do
local file = {} -- I'm adding a table as a value
file[1] = category.Name
file[2] = item.Name
file[3] = item.Amount.Value
inventoryToSave[itemname] = file -- The index for the tables is the name of the item
end
end
print(#inventoryToSave) -- This prints 0, meaning that the items aren't going through
dataStore:SetAsync("ExampleKey", inventoryToSave) -- Here is where I send the table to be saved
I've tried taking off the 'local' part but it still doesn't go through and I really am stuck on this. If anyone could please help I would be so grateful. Thank you!

1 comment
Code block please. At least inline code.