#table returns zero even though there are items inside

I need to know, how does this table when asked the length of,

{["ItemID"] = 1}

return 0?

Also here is more completed code if you want ig

for i,v in pairs(returneddata[tostring(player.UserId)]["InventoryData"]) do
		if #v > 0 then
			if i > #returneddata[tostring(player.UserId)]["InventoryData"] - 3 then
				local newitemUI = game.ReplicatedStorage.Game.UIComponents.InventoryTemplate:Clone()
				newitemUI.Name = itemdataModule[v["ItemID"]]["Name"]
				newitemUI.Itemicon.Image = itemdataModule[v["ItemID"]]["Icon"]
				newitemUI.Parent = gui.Container
			else
				local newitemUI = game.ReplicatedStorage.Game.UIComponents.InventoryTemplate:Clone()
				newitemUI.Name = itemdataModule[v["ItemID"]]["Name"]
				newitemUI.Itemicon.Image = itemdataModule[v["ItemID"]]["Icon"]
				newitemUI.Parent = gui.Inventory.Container
			end
		else
			continue
		end
	end
end

any help is appreciated! :grinning:

1 Like

Unfortunately dictionaries don’t have “numerical indices,” therefore the length of one cannot be determined. You’ll have to loop through the dictionary and increment a variable as a count.
Same issue someone else had (with solutions)

1 Like

I tried it, and it works!
Weird how they don’t count dictionaries, but atleast it works now! thanks! :smile:

2 Likes

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