All global variables are always accessible through any file with the same type (server/client) as the file they were defined into. Putting them in a function will just define them as if they were "new" upon function call (unless you localize them, so they're accessible only within the function's scope). It's also notable that you cannot access any variable from another resource. Instead, you can always use call or "exports" table. Anyways, i think you need to learn the basics of Lua variables or the basics of Lua if needed.
http://www.lua.org/pil/1.html (Getting Started)
http://www.tutorialspoint.com/lua/index.htm (Recommended)
http://www.lua.org/pil/4.2.html (Local Variables and Blocks)
http://lua-users.org/wiki/ScopeTutorial (Scope Tutorial)