The # operator only works on the array part of a Lua table, the part with consecutive natural number indices. There is no shortcut for counting keys in a dictionary, you’ll either have to increment/decrement your own counter, or run a pairs for loop on the table and count how many times it loops.