How can I insert another table's value into a table

This is a really stupid problem I cant seem to fix.
I use the line table:insert(text, keys[cl]) where text is a table, keys is a table, and cl is a number value (I have tried this where instead of cl its just a number but that doesnt work)
I get this error when I run the script: “invalid argument #2 to ‘insert’ (number expected, got table)
Is there any way I can fix this?
Thanks!

Try using table.insert.

Table:insert and table.insert are different.

1 Like

Thank you, Im not the smartest. This solution worked.

For future reference, table:insert is the table itself. So:

local Table = {};

Table:insert("What to insert!")
-- OR --
table.insert(Table, "What to insert!")
1 Like

In this case table:insert would be invalid, the ‘table’ libraries __index metamethod does not point to itself.

The ‘string’ library is the only library where functions can be called with the colon operator. In native Lua various ‘io’ library functions can be called on ‘file handles’ (effectively file objects) with the dot operator.

Good catch! Thank you for correcting me. Now I know for the future!