I tried to use module scripts, but I need to access that table from other server scripts as well, so that wouldn't work.
I tried to use _G
, but _G
is different for local scripts and server scripts.
Basically what I want is for a server side script to create a table of items, and I want a local script and other server scripts to be able to access that table. Any suggestions?
MY PURPOSE:
I'm designing a Helicopter kit, which will be a successor to my Military Planekit V2. The Helicopter kit will have 1 script that regens the helicopter, welds it, and checks if it crashed. The weld part of the script will also weld rotors, so that they can spin, and I store those welds in a table. I want to access that table from a Hopperbin, so that when a player starts the helicopter, the localscript will access that table of welds instead of scanning the helicopter for rotor welds.
Ever thought about using Remote Functions? You can use them to pass functions from a server script to a local script and vice versa.
Server Script:
local remoteFunction= game.ServerStorage.RemoteFunction -- Location of RemoteFunction function remoteFunction.OnServerInvoke() local array = {'Hello World'} -- Do what you wish to generate this return array end
Local Script:
local remoteFunction= game.ServerStorage.RemoteFunction -- Location of RemoteFunction local array = remoteFunction:InvokeServer() print(array[1]) -- Will print 'Hello World' in this case