Why is this value returning nil?

I’m trying to insert items into a table in a certain order, and for the most part it’s working, but for some reason one item keeps returning nil no matter what I do (even though the entity exists and is labeled correctly.)

local mineLevelTable = {}
for i, v in pairs(mines:GetChildren()) do
table.insert(mineLevelTable, v.index.Value, v.mineLevel.Value)
end

for i = 1, #mineLevelTable do
print(mineLevelTable [i])
end

This prints:
0 (x5)
nil
0 (x5)

when it’s supposed to print

0 (x11)

Why?

I appear to have misunderstood the question. I have tossed my original reply. I apologize.

Please be certain that the ‘index.Value’ isn’t set to a nil value when the for loop is running through all of the mine-levels. This is the only case I can think of as to why it is doing this.
Else-wise I am going to need further information if I am to assist you in your problem.

Could you provide a screenshot of the hierarchy?

This isn’t all of it, but it’s just the same thing 11 times with different names.

Here’s a video showcasing my problem:

For every index.Value, do they go from 1 to #mineLevelTable with no gaps?
Check that your mineLeveltable isn’t “disjoint”.
Otherwise, if it is, the length operator returns the last numeric key whose value is not nil for tables starting from 1. I think that you are missing a v.index.Value of 6 I think.

Yes. All of the index values go from 1-11 with no gaps.

Forget it. I’ll do it a different way.

See what this does:

local mineLevelTable = {}

for i, v in pairs(mines:GetChildren()) do
    mineLevelTable[v.index.Value] = v.mineLevel.Value
    print(v.index.Value, v.mineLevel.Value)
end

for i = 1, #mineLevelTable do
    print(mineLevelTable[i])
end