You can’t use table.find directly on a nested table like t . The function table.find is designed for flat arrays, and it won’t work as expected on tables with nested structures. You will need to do it like that:
In your case, where t is a table of tables, you’ll need to iterate through the outer table and then check each inner table for the value you’re looking for. Here’s how you can achieve this:
local function ScanTableToFindIndexByValue(array, value)
for i = 1, #array do
local content = array[i]
local index = table.find(array, value)
if index then
return i, index
end
end
end
local i, index = ScanTableToFindIndexByValue(t, value3B)
print(i, index) -- 3, 2
print(t[i][index])