"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:
- A Player's Backpack, such as a child of a Tool;
- A Player's Character model;
- A Player's PlayerGui;
- A Player's PlayerScripts; or
- The ReplicatedFirst service.
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:
- Is network filtering enabled? And, if so, should changes be replicated to all players?
- Do I need to process user input, manipulate the GUI or Camera?
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. :)
1 comment
https://scriptinghelpers.org/questions/31374/should-i-use-a-local-or-regular-script#34551