I have multiple LocalScripts that are inside a player model, but what I have intended won't work unless there's a way to make thouse scripts' variables(values) available through all of them, but not through anything else. Also I want thouse scripts to still function properly even if i clone them to different players on the same game, same server.
For example, I want to be able to do something like this:
Script1: local x = 1
Script2: local x = script.Parent.Script1.variable(x) print(x)
Output: Script2: 1
Of course there is a reason why I can't simply make the variable inside the same script. It's because the variable will be modified by a loop and I already have a loop inside the script in which I would want to have that variable(value).
I've heard of a method that would make the variable available to all scripts, but if it is cloned, then there'll be just a mess of multiple same name variables with different values.
This is usually a bad idea because it's very confusing and easy to mess up.
ROBLOX gives you controlled ways for scripts to communicate with each other.
ModuleScripts let you define a script that "exports" an interface to different scripts. The object is shared among all server scripts / all localscripts on a given client, which means you can share local variables however you want, usually behind functions.
BindableFunctions are another way for scripts to talk to each other using functions.
You could also use plain old IntValue, ObjectValue, StringValue, etc. objects, but these are only the right way to organize your code from time-to-time.
If you explain specifically the kind of information you want to share, I could suggest a manageable way to set up your scripts.