Hi, I was wondering if it was possible to put a table inside of a global function to transfer it to another script. Here is an example I tried:
Inside Main Script:
_G.test = function() local try = { Num1 = "Hey", Num2 = "Hello" } print(try.Num1) end
Inside Other Script:
_G.test()
Error Workspace.Script:1: attempt to call field 'test' (a nil value)
I couldn't get it to work. Could someone help me or at least explain it?
_G.test is not guaranteed to exist the moment you attempt to call it in the other script. You need to yield the thread until it exists. This can be done with a simple while loop.
-- We are going to wait until _G.test's variable type is a function instead of nil while type(_G.test) ~= "function" do wait(0.03) end _G.test()