Script Context
Every .lua
script runs in isolation of every other .lua
script. This means that each script has no knowledge of the other, and all variables are completely isolated.
For example, if you declare a non-local variable in one script:
-- resources/test/client/main.lua
MyGlobalVar = 1
Another script in the same resource (or any other resource) cannot access it:
-- resources/test/client/main2.lua
print(tostring(MyGlobalVar)) -- Prints "nil"
If you want to share static data and functionality between scripts (eg. in the example above), you can use Modules. If you want to share dynamic data between scripts at runtime, such as telling a script to add one to a counter when a user does an action, you can use Events.