LocalScript
Summary
A LocalScript runs on the client (the player’s machine). Use LocalScripts for client-only behavior such as UI, camera control, and input handling; do not use them for server-authoritative logic.
Typical properties / methods
Parent: Instance — where the script is placed (e.g., a PlayerGui or StarterPlayerScripts).Disabled: Boolean — whether the script is currently disabled.Source: string — the script source (editor-only / read-only in some tools; not guaranteed to be available at runtime).
Example
-- Example LocalScript that prints the local player's namelocal Players = game:GetService("Players")local player = Players.LocalPlayerif player then print("Hello, " .. player.Name)endNotes
Players.LocalPlayeris only available in client / LocalScript contexts; it will be nil in server scripts.- LocalScripts do not run in server-only containers such as
ServerScriptService. - Avoid trusting client-side code for security, permissions, or authoritative game state — always verify on the server.
- Good placements for LocalScripts:
StarterPlayerScripts,StarterGui/PlayerGui,StarterCharacterScripts,Backpack(for tool-local behavior).