Board Thread:Lua Help/@comment-27393108-20160204065606/@comment-24473195-20160204085612

> Are global variables shared between instances of a Lua script?

Not sure what you mean, but you can only access global variables within the lua script it is defined. If you call the lua script again using a different "{{#invoke" it will not contain those variables changed previously.

> Are there even different instances of a Lua script or does the wikitext parser simply keep the script open until the page is rendered?

Each script is within its own sandbox when you create a new instance. You can't pass variables between them or access the previous ones. This is by design.

> Would it be possible to create a template that stores data in a global variable and access that global variable from another template within the same page?

No. Unless you use something like the mw:Extension:Variables which wikimedia developers strongly discourage, but wikia allows.