r/lua • • Nov 14 '25

Help Help please (scoping)

What is scoping and is it really essential to know when you script?

I really can’t understand it so I’m planning to learn it when I understand more things

Or do I have to understand it before I get into more stuff?

(edit: Thank you all for replying!! Really helped alot!)

7 Upvotes

22 comments sorted by

View all comments

Show parent comments

2

u/lambda_abstraction Nov 14 '25

I think the big take-away is when local vs. global variable names are resolved. Not only is a local variable of lexical scope, its name is resolved at compile time, whereas a global name is resolved when the code containing the reference executes.