Hey guys,
Quick question regarding module scripts,
I haven’t had the chance to test this, but was just wondering
if I did something like this.
example.
ModScript
local modScript = {}
local data = {}
modScript.setTest1 = function(data1)
data.test1 = data1
end
modScripot.getTest1 = function()
return data.test1
end
return modScript
Script0
wait(2) -- wait 2 seconds to allow Script1 to execute first
local modData = require(script.Parent.ModScript)
modData.setTest1(25)
Script1
local modData = require(script.Parent.ModScript)
print(modData.getTest1()) -- output nil
wait(3) -- wait 3 seconds, Script0 should have assigned the value 25 to data.test1
print(modData.getTest1()) -- should output 25
Process:
Script 1 calls getTest1(), return nil, not set
Script 0 call setTest1(), set value @ 25
Script 1 calls getTest1(), now returns 25
Is this correct in regards to how module scripts work?
in script1, will modData reference ModScript? in that any future changes made via other scripts will not require calling modData = require(script.Parent.ModScript) again to get the latest changes, as in the above example.