| |
|
|
| 17 Feb 2015 07:49 PM |
LocalScripts 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 a LocalScript, using the LocalPlayer property of the Players service will give you the player that has the script, which is the LocalPlayer. For example, in a LocalScript, if you have this code, then the player will be killed.
In order for a LocalScript 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 PlayerGui
(Note: a LocalScript does not need to be directly within one of these places, but must at least be a descendant of them, for example, a LocalScript inside a Tool inside their Backpack.)
If a LocalScript is not inside one of these locations, it will not run its Lua code. See Scripting for information about creating custom scripts.
(Source: http://wiki.roblox.com/index.php?title=Local_script)
Go there ^
"I like to program." - Bosswalrus |
|
|
| Report Abuse |
|
|
| |
|
Bitwyl
|
  |
| Joined: 15 Nov 2014 |
| Total Posts: 7276 |
|
|
| 17 Feb 2015 07:52 PM |
| short and sweet version, for player services mostly |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2015 07:52 PM |
LocalScripts are usually used for accessing the Player(From my experience).
"I like to program." - Bosswalrus |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2015 07:55 PM |
Using a local script allows you to easily access the properties of certain objects which may only appear to the client and not the server. A great example is the 'Camera'. If you want to adjust only that local clients camera; you'd use a localscript. Also, it makes it much more of ease to monitor one player.
For example; You can do something such as:
context = game:GetService("ContextActionService") plr = game.Players.LocalPlayer or game.Players.LocalPlayer:wait()
context:BindActionToInputTypes( "spacy", function() print(plr.Name, " hit spacebar!"), false, Enum.KeyCode.Space)
As you might be able to see from the above; it allows us to also check when individual players interact with the game. We can successfully (and more efficiently) make changes to a characters game experience based on what they do.
Local scripts are great for being able to monitor over individual people and making changes visible to them.
|
|
|
| Report Abuse |
|
|