I'm trying to get the table of my hats to be saved but it doesn't seem to work!?

Function

function module.savehats(player)
	warn("A")
	--if cansavehats == true or alredysavedhats == false then
		
		local HatsTableSave =  {}
		
		local Inv = player:WaitForChild("Inventory")
		
		warn("B")
		
	for i,v in pairs(Inv:WaitForChild("Hats"):GetChildren()) do
		table.insert(HatsTableSave, v.Name)
		table.insert(HatsTableSave, v.Value)
		table.insert(HatsTableSave, v:WaitForChild("ImageID").Value)
		table.insert(HatsTableSave, v:WaitForChild("Rarity").Value)
		warn("C")
	end

		local function checking()
			HatsData:SetAsync(player.UserId, HatsTableSave)
			warn("D")
		end

		local sucess, err = pcall(checking)
		
		if sucess then
				warn("S")	
		else
			print("Error while saving: "..err)
			local plr = player
			module.savehats(plr)
		end
	--end
end

It only prints up to "C", then stops!? Nothing after that prints? What am I doing wrong???