Can you show the full error message? You might be calling the function somewhere else without realizing it. You can also ctrl+f for any other calls if you prefer.
Since you are setting smallest to false when you ‘return false’, the following calls on getSmallestBlock() will send ‘false’ instead of an array. It’ll then error as you can’t index [2] of false.
Is line 55 the first or second call to getSmallestBlock? I think what’s happening is that it’s being put inside the alreadyCheckedTable the first time you call the function and the second time it won’t return anything since alreadyChecked would be true.
The only way it could return nil is if alreadyChecked is true, so that’s probably the issue. Out of curiosity, why does it matter if it’s already been checked?
Where do you check it? I don’t see any other way this could be returning nil, so I’m out of ideas. Try printing after the second end if that’s not where you already tried.
A potential fix could be this:
-- instead of this:
if true then
smallest = whatever
end
-- do this:
smallest = getSmallestBlock(block, smallest) or smallest