How do i get table from a script, in a different script

Hello!
I am trying to get a table from a script in a different script. Anyone know how to make it?

One way would be to use modules
https://education.roblox.com/en-us/resources/intro-to-module-scripts

Both scripts would require the same module and now you can access the same data in the module

-- script 1
local module = require(game.ServerStorage.ModuleScript)

-- save a table into the module
module.table = {5, 8, 3}
-- script 2
local module = require(game.ServerStorage.ModuleScript)

-- wait a little to give script 1 some time to run
task.wait(10)
-- print the table in the module
print(module.table)

Another option is to use bindableevents
https://developer.roblox.com/en-us/api-reference/class/BindableEvent


Another option is to use _G

-- script 1

-- save a table into the _G
_G.table = {5, 8, 3}
-- script 2

-- wait a little to give script 1 some time to run
task.wait(10)
-- print the table in the _G
print(_G.table)
1 Like