What is the point of local scripts?

Hello scripters,

I just wanted to ask what the point of using Local scripts is over a normal script. I know what local scripts do, however I m not sure for what sort of scenario we would be using them over normal scripts. Any replies relating to the topic would be really helpful. Thanks in advance.

Have a nice day!!!

1 Like

To start of with, there are a lot of functions commonly used which are not available on the server. There are also certain scenarios where you do not want to replicate actions of the client to other players.

While it may not be super relevant to your question, this article explains some more things about the client-server model.

Edit: The client is also often better suited for resource intensive tasks where you for example might be required to render something constantly.

1 Like

Severscripts run on the server, localscripts run on clients computer.

You usually use localscripts for scriptting GUIs, making changes on workspace that only that client in question should see and detecting user input detection.

1 Like

They are great for running tweens locally. A rotating coin as a pickup could be run in a local script, so all the rotations are not sent from server to client.

1 Like

Thank you guys for your replies, reading these gives me a better idea as to why we would use Local Scripts. Many thanks!!!

1 Like

Server scripts would be used when you either wanna hide information from the client, affect the whole server, or for general security.

Local scripts would be used when you wanna affect solely the client, not sending sensitive information, and as a easier way to get player information.

1 Like

So lets say we would want like all the prisoners in the server, like Jailbreak, to wear prisoner clothes, would we use a server script for that or a local script?

Server Script, with an OnPlayerAdded or OnCharacterAdded and cloning the clothes from ServerStorage.

1 Like

oh ok thank you, I thought it was server script too