Visibility

A local variable (including parameters) in a function body has precedence over a global variable of the same name.

Global variablesmay be used in a function body as long as they are not shadowed by local variables with the same name from enclosing functions.

A function cannot access a local variable from an enclosing function. However, a function may access the value of a local variable from an enclosing function, using upvalues.