in what instance is it best to use a local script, and when is it not?
I've also wondered about whether or not all information in local scripts is always on the clients with those scripts, for example if I changed the torso transparency of an individual with a local script would other clients see those changes, or only that individual? (like with GUIs, for example)
"LocalScripts" operate on the client; the player's computer. For this reason, they are also called clientside scripts.
Regular "Scripts" operate on the server; a really powerful computer located at the Roblox Headquarters which is responsible for hosting the game. For this reason, they are also called serverside scripts. Any change made to the server is "replicated" to all clients.
-
Now, depending on whether or not the FilteringEnabled
property of the Workspace is enabled, LocalScripts may or may not be able to interact and change properties of objects on the server directly.
If it is enabled, the server will reject any changes from the clients, and so changes made from a LocalScript will only be noticeable by the player who owns said LocalScript (the local player).
Otherwise, if FilteringEnabled
is disabled, the server will accept the changes and all players will notice them. An exception to that rule is the local player's humanoid. Any change made to the local player's humanoid will always be replicated to the server.
-
LocalScripts are generally used to handle user input, manage GUIs or manipulate the camera. LocalScripts will only execute if they are a descendant of:
Additionally, the ancestry of a LocalScript will determine on which client it shall be executed on.
-
Conclusion:
So the answer would be, when inserting a new script, ask yourself these two questions:
If you answered 'yes' to the first question then you should use a regular Script;
If you answered 'yes' to the second question then you should use a LocalScript;
If the answer is both a regular Script and a LocalScript then you should use both, and communicate through them using RemoteEvents and/or RemoteFunctions.
I Hope this helped. If so, please be sure to mark my answer as accepted and, optionally, give an upvote. It helps both of us. :)
Locked by User#24403, ee0w, and yHasteeD
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?