I have a variable in a LocalScript that I would like to use within other scripts. However, according to the wiki, "in Online mode, scripts running in a LocalScript run on the player's computer, so they are in a separate instance of Roblox and can't share data with non-local scripts except by using objects such as IntValue."
What does it mean I can use IntValue to scare data with non-local scripts? How do I do that?
You cannot use _G
to share information between LocalScripts on different clients, or Scripts and LocalScripts.
You can use changes to the game world, like setting NumberValue objects or other objects when those changes are replicated to other clients -- these are communicated between LocalScripts on different clients and to the server.
However, not all changes to objects are replicated. Certain objects like Messages that created by LocalScripts aren't replicated. As a consequence, their children and properties will not be shared with the Server or with other clients. In addition, if Workspace
's FilteringEnabled
is enabled (which it ought to be whenever possible for security reasons), then no changes replicate.
Scripts and LocalScripts can always communicate via RemoteFunctions which are secure and act similarly to functions store in _G
, except that they are placed in the hierarchy of ROBLOX objects.