Can I localize a function with a table?

Just wondering if I am doing this right, or just causing issues.

local myTable = {}; --Global Function; function myGlobalFunction(); print("Hello!"); end; --Local Function; local function myLocalFunction(); print("Hello Again!"); end; --Now, is this also local? function myTable.function(); print("Hello Again Again!!"); end;

Is using myTable.function() also a local function?

Yes, myTable is a local variable, so myTable.functionName() would also be local, however you’ll get an error if you try with myTable.function() as you can’t use reserved words as function names.

Also, you should make it a habit to always declare everything local.

Globals are hardly ever needed.

I try to use local variables unless I need global, although in a very complex situation I’d rather use a table.

I understand my error with myTable.function();

It should read; myTable.myFunction();

But still using myTable.something is local, long as myTable is local, correct?

Yes, correct.

Thank you for your assistance

Yes, myTable is a local variable, so myTable.functionName() would also be local, however you’ll get an error if you try with myTable.function() as you can’t use reserved words as function names.

Also, you should make it a habit to always declare everything local.

Globals are hardly ever needed.

I try to use local variables unless I need global, although in a very complex situation I’d rather use a table.

I understand my error with myTable.function();

It should read; myTable.myFunction();

But still using myTable.something is local, long as myTable is local, correct?

Yes, correct.

Thank you for your assistance