function TestIter(t) local i = 0 local n = table.getn(t) return function() i = i + 1 if i <= n then return t[i] end end end table1 = {"A", "B", "C"} table1["A"] = "hello" table1["B"] = "lua" table1["C"] = "world" table2 = {"A", "B", "C"} table2["A"] = {} table2["A"].x = "hello" table2["B"] = {} table2["B"].x = "lua" table2["C"] = {} table2["C"].x = "world" function Squishy:Test() for obj in TestIter(table1) do print(obj) -- works end for obj in TestIter(table2) do print(obj.x) -- attempt to index local `obj' (a string value) end end