So I’m trying to loop through a table within a table that stores some info I need, and I’m trying to check a certain index but it prints nil, but I know that the table values inside arent nil because I loop through and print them and I can see each value, any idea whats going on?
This is what the print(value) prints
This is what print(v[1]) prints
for i,v in pairs(UncompleteM) do
print(i,v) -- v is the table inside of uncompleted missions
for index,value in pairs(v) do
print(value) -- stuff in inside of the table
end
print(v[1]) -- Im trying to print the first index of v which is the table inside of UncompleteM.
end
It looks like you are using a dictionary (Also known as a Hash Map) which the values cannot be indexed with integer values. If you print the index you will see that things other than integers. If you change your loop from pairs to (iterative pairs) ipairs, the dictionary will still appear to be empty
Two things I can think of off of the top of my head - so you know ‘1’ is a value, but are you sure it’s an index? And the second thing I would try is double check the typing on your index, because in some cases it’s possible to have an index of “1” (string) but what you want could be 1 (a number).
It’s kind of hard to tell without seeing your table, but it’s a start!