The title says most of it but I have little note to add. What does it mean when people say module scripts return the same value when called in the same environment multiple times and how does that affect me?
It means a module script will always return the same value.
--In a module script return math.random(1,9)
--In a script while true do print(require(script.ModuleScript)) wait(1) end
And it only prints 1 number, every second, the same number.
--Another example moduleScript return game.Workspace.Value.Value
--Script while true do print(require(script.ModuleScript)) --prints the original value repeatedly game.Workspace.Value.Value = game.Workspace.Value.Value .. " and antoher one" wait(1) end
So here, the module script doesn't run twice, it only looks up what it returned previously, and gives returns that, even though the value it looks at changes.
Explain it a bit better: A module script runs once, and only once. Adding a print statement to the beginning will show this:
print("Important code bits") --The above only prints once return game.Workspace.Value.Value
And if it is required again, it just returns what it did the previous time it was required.
Reasons? The same reasons anything caches, to improve performance. Module scripts shouldn't be used to return values like in the above examples anyway.
As for the same environment thing, a module script would be ran once from the server, and once on each client that requires it.
return game.Players.LocalPlayer
Would return nil
if required from a serverScript, and return the local player if required from a LocalScript.