Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to share global variables through LocalScripts?

Asked by
emite1000 335 Moderation Voter
10 years ago

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?

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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.

0
I tried looking up and learning RemoteFunctions, but it just hurt my head. I get what you're saying though. emite1000 335 — 10y
Ad

Answer this question