So I have a module script which contains important information. I want the changes to the module to be global, in other words, when I modify the module’s content, the other scripts will also receive effect.
Here is an example of what I mean:
Module script
local module = {}
module.Word = "original"
return module
Script 1
local mod = require(game.ReplicatedStorage.ModuleScript)
mod.Word = "new word"
print(mod.Word) --> new word
Script 2
local mod = require(game.ReplicatedStorage.ModuleScript)
print(mod.Word) --> original
How can I make it so that script 2 can see the changes that script 1 did to the module?
You’d need to run the function on the client as well. When the server makes the change, you can fire a RemoteEvent to the client to change is as well. Fire the info along with it.
--server
RemoteEvent:FireAllClients(newInfo)
--client
local function update(newInfo)
yourModule:ChangeInfo(newInfo)
end
RemoteEvent.OnClientEvent:Connect(update)
well it seems a bit pointless… just pick one of them. The first one was probably more helpful than the second because it told you how to edit it in the module. Glad I could help though.