Ad
Log in to vote
4

When should you use a LocalScript and when should you use a Script? [closed]

Asked by
Ozzypig 160
3 years ago

I have a script that is meant for a GUI that displays the value of a StringValue in the workspace, but I don't know if I should use a LocalScript or Script.

0
I don’t think this should be tagged with efficiency. Efficiency doesn’t seem very relevant to me. MarkOtaris 205 — 3y

Locked by ConnorVIII, adark, 1waffle1, and Thewsomeguy

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

3 answers

Log in to vote
2
Answered by 3 years ago

You should always use local scripts for tasks related to user input, including everything related to mouse or keyboard input as well as user interfaces and camera manipulation. Tasks directly dependent on user input (including actions performed by tools in result to user input) should also be done with local scripts. For everything else, scripts that run on the server should be used. The server and the clients can communicate using the RemoteFunction and RemoteEvent objects.

2
Also note that local scripts can be modified by the client Quenty 200 — 3y
1
That can be a big security hazard in some games. Quenty 200 — 3y
1
Thanks for filtering enabled now ^.^ http://wiki.roblox.com/index.php?title=FilteringEnabled_(Property) Nickoakz 230 — 2y
Ad
Log in to vote
1
Answered by
Unclear 1621
3 years ago

You should use a LocalScript if you plan on using the features that LocalScripts give you.

But, if you're afraid of the StringValue in workspace being edited for some reason by the client (exploiter?), you can always hide it by putting it in ServerStorage instead. Then, you would use a regular Script to access it.

However, if the script is only doing a small task like that, I would probably trust the client to handle it and have the code execute through a LocalScript.

Log in to vote
-3
Answered by 2 years ago

Use local scripts if you want it to be apart of for example something in the StarterPack to customize that object. Its used for 1 thing only. And you can use the regular script if your using it for a simple part. Like changing the appearance or an event. So local script and regular script are kinda alike.

Ad