Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

What's the difference between a Script and a LocalScript?

Asked by 9 years ago

I've heard people say "Scripts and LocalScripts are different. LocalScripts have limits." However, I got absolutely nothing from those responses. I'd like to ask for a more in-depth response. Can somebody list the pro's and con's for each object?

2 answers

Log in to vote
5
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Why is there a difference at all?

Here is a similar question where I cover why there are the two varieties:

What does game.Players.LocalPlayer mean?


When do I use which?

Things that are running the game itself and don't care about any particular player should (usually) be a Script object.

Things that care specifically about the details of each player, for example, anything interacting with their mouse or keyboard or GUI, should probably a LocalScript (because of the latency).


Where they run

Scripts will run in ServerScriptStorage and the Workspace, and inside PlayerGuis and Tools/Hopperbins. Perhaps there are a few other places, but it would be bad practice to utilize such.

LocalScripts will only run inside of a Player's Backpack, PlayerGui, or their Character.


Different Functionalities Available

LocalScripts enable several functionality:

While Scripts get market, teleportation, http services. (Anything that involves communicating with the "outside" of the running game needs to be done server-side from a normal Script)


Filtering Enabled

FilteringEnabled, which is not on by default but is considered current best practice for ROBLOX developers, means that any and all changes made by a LocalScript are ignored by all other players. That means a LocalScript with FilteringEnabled can't do anything that any other player can see (but they can still manage things like GUIs or special effects that are only seen by the LocalPlayer)

You would use RemoteFunctions or similar to allow LocalScripts to affect the game world with FilteringEnabled on.

Ad
Log in to vote
2
Answered by 9 years ago

Local Scripts differ from regular Scripts as they do not run server-side, but instead, perform their actions on the client. This makes them incredibly useful for accessing the properties of certain objects which may only appear on the client and not the server, such as a player's Camera.

In order for a Local Script to function, it must be placed within one of three areas: -In a player's Backpack (can be indirectly, through a Tool or HopperBin) -In a player's character model -In a player's Player Gui

(Note: a Local Script does not need to be directly within one of these places, but must at least be a descendant of them, for example, a Local Script inside a Tool inside their Backpack.)

In my experiences I find Local Scripts more useful when I'm making gear, Besides that I find Scripts better

Answer this question