Is it possible to edit variables in a Module and have those edits shared across Services?
I've created the following:
StarterPlayer/StarterPlayerScripts/test (ModuleScript)
local module = {}
module.x = 10
function module:setX(value)
self.x = value
end
return module
StarterPlayer/StarterPlayerScripts/test2 (LocalScript)
local test = require(script.Parent.test)
test:setX(5)
print(test.x)
- outputs 5
StarterPlayer/StarterPlayerScripts/test3 (LocalScript)
local test = require(script.Parent.test)
wait(5)
print(test.x)
- outputs 5
StarterPack/Kickball/tool (LocalScript)
local test = require(game.StarterPlayer:WaitForChild("StarterPlayerScripts"):WaitForChild("test"))
wait(6)
print(test.x)
- outputs 10
I would have expected the last script (tool) to output 5 since the other script changed the value but this is not the case, it's like the module was copied fresh

1 comment
Had a little discussion with some other guys as to why this is but it's because Playerscripts are cloned to the Player.PlayerScripts, which makes script.Parent and game.StarterPlayer two separate instances and thus 2 different contexts (thanks to hiimgoodpack)