I want to modify values in a modulescript array using the first script and modify them in another one.
When I’m saving data using table.insert in the first script and requiring the modulescript again in the other one, it’s not saved.
I’ve tried looking for a way to save and load big tables containing instance information, I’ve found modulescripts are the way to do it properly, as I didn’t want to use _G variables as people said they tend to be buggy and sometimes not work.
-- modulescript:
local module = {}
return module
--first script:
local module = game.ServerStorage.ModuleScript
local moduleTable = require(module)
table.insert(moduleTable,#moduleTable+1,"Data")
-- second script:
local module = game.ServerStorage.ModuleScript
wait(1)
local moduleTable = require(module)
print(moduleTable[1])
Expected output:
“Data”
Actual output:
nil
Am I doing something wrong? How can I make it print out the expected result?
EDIT: nvm this all works and the expecte output is the same as actual output, i was doing something wrong