[ Index / Tables ] Not working accurately?

So, I’m keeping my ViewportFrames stored in a table:

local _ViewportFrames = {}

Each _ViewportFrame will have two variables - A & B:

_ViewportFrame[Child] = {_1 = PortalCass.FromPart(_Model[Child]["_1"], Enum.NormalId.Front, Player:WaitForChild("PlayerGui")), _2 = PortalCass.FromPart(_Model[Child]["_2"], Enum.NormalId.Front, Player:WaitForChild("PlayerGui"))}

When I want to remove the required variables, I’m attempting to index through the table using:
for i = 1, #_ViewportFrames do end

However, I’m getting no results. Not even a print-out when I’m attempting to debug.

PortalCass.Remove = function(Child)
	for i = 1, #_ViewportFrame do
		if _ViewportFrame[i] == Child then
1 Like

When some of the items are stored in dictionary format, they don’t contribute to the actual size of the table.

local tab = {
 Dict1 = 1;
 Dict2 = 2;
 Dict3 = 3;

print(#tab) --prints "2"

So for your case, I think it would be better to loop in pairs:

for key, val in pairs(_ViewportFrame) do
1 Like