Hello,
I know shared and _G are almost the same, but is shared able to go client side and server side like _G cant?
-- Server side shared.Asd = function() return "asd" end -- Client side print(shared.Asd())
_G cannot do these things, but since shared is SO old and never been updated could it work under client and server being the same table?
No. Tables can store arbitrary objects and functions. Consider this on the server:
local blah = {} function _G.set(x) blah = x end function _G.get() return blah end
I could then do this on a client:
local mine = {} _G.get().hello = mine mine.blah = _G.get()
Now blah
, which resides in the server's memory, refers to mine
, in the client's memory (and vice versa). Managing this is sort of ridiculous and doesn't make any sense. When you say _G.get()
, how long do you wait? What if the value has since changed?
You have to properly use RemoteEvent
and RemoteFunction
s. These give a safe, simple filter that connects the client and the server.
If you really are uncomfortable using them, you can of course do some magic with modulescripts / metatables / whatever you want to take advantage of RemoteFunction
s behind-the-scenes.
Locked by MessorAdmin, XToonLinkX123, Perci1, and woodengop
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?