of     1   

LuaDesign
#227685960Saturday, November 18, 2017 10:15 PM GMT

Say I want to share a table throughout the server scripts. Is _G not a good way to go or is there a different method? If I had a penny for every penny I had... Mother of god.
iiNemo
#227685991Saturday, November 18, 2017 10:16 PM GMT

Just don't use global variables at all. Fish Are Friends, Not Food
LuaDesign
#227686020Saturday, November 18, 2017 10:17 PM GMT

Then how would I share a global table? I'm looking for advice not a do not. If I had a penny for every penny I had... Mother of god.
cntkillme
#227686022Saturday, November 18, 2017 10:17 PM GMT

_G is fine but the problem is all scripts can access it, which may not be a problem now but if a later script decides to mess with _G it can potentially ruin things. ModuleScripts are a cleaner solution mainly because you only have access to what it returns when you require it, otherwise you don't.
Soybeen
#227686029Saturday, November 18, 2017 10:17 PM GMT

Sure, it's absolutely fine if you know how to use it. People who say "never use global variables ever for any reason whatsoever forever and ever amen" typically don't know everything about them, or how to manipulate them safely.
76km
#227686073Saturday, November 18, 2017 10:18 PM GMT

@op if you don't want to transfer a global table, you could make the individual scripts generate a table whenever required rather than just have a table strung everywhere? idk, inefficient suggestion, but.
LuaDesign
#227686098Saturday, November 18, 2017 10:19 PM GMT

So could I do this? -- Module local module = {}; module.var = 42; return module -- Script A local module = require(module) module.var = 1000; table.insert(module, "ok") -- Script B local module = require(module) print(module.var) for i,v in pairs(module) do print(v) -- Would print 1000 and ok end If I had a penny for every penny I had... Mother of god.
iiNemo
#227686118Saturday, November 18, 2017 10:19 PM GMT

_G on the server stays on the server and cant be accessed by the client, _G on the client stays on the client and cant be accessed by the server Fish Are Friends, Not Food
JarodOfOrbiter
#227686151Saturday, November 18, 2017 10:20 PM GMT

Yess, you can do that.
iiNemo
#227686188Saturday, November 18, 2017 10:21 PM GMT

Just used Bindable Events/Functions Fish Are Friends, Not Food

    of     1