Want a special badge and 30 bux? Make some PolyWorld! Content and post it in the Creations forum!
Dark mode is incomplete! Please report any issues to the Discord.

LocalScript

LocalScripts Not creatable

LocalScripts run Lua on each player's client.
They use a smaller API focused on local visuals, the local Player, and talking to the server with MessageModule.

LocalScripts do not share globals with other players or with server Scripts.
The global script refers to the running LocalScript.


Overview

Properties

Methods

Events

Prefer Connect on the parent Part when present:

EventWhere
Clicked`Part.Clicked`
Touched`Part.Touched`

Older global handlers are listed below as deprecated.


API

Properties

Parent

Parent : Instance?
The local Part this LocalScript is attached to, when parented under a Part.

script.Parent.Clicked:Connect(function(player)
    print("clicked")
end)

parent

parent deprecated : Instance?
Identical to Parent.
No longer recommended for use.

Methods

FireServer

FireServer(name: string, data: any?) : void deprecated
Sends a remote event to the server.
Prefer `MessageModule:MessageToServer`.
No longer recommended for use.

FireServer("tool_use")
Events

Touched

Touched(player: Player) deprecated
Older global handler for when the local player enters the LocalScript's parent Part.
Prefer `Part.Touched:Connect`.
No longer recommended for use.


Client globals

LocalScripts have access to:

GlobalNotes
wait, printSame idea as Scripts
playerThe local Player
PlayersClient-only: `GetLocalPlayer` (same as player)
workspace, WorkspaceRead-only lookup of existing Models and Parts
UILocal Notify and Hud only
RGBColor, Vector3, ExplosionValue helpers and local VFX
Instance`Instance.new("Part")` creates a client-only Part
InputModule, RaycastModuleLocal input and picking
PlayerMovementModule, CameraModuleLocal movement and camera
TweenModuleLocal Part tweens

Not available on the client: server Players (GetPlayers, PlayerAdded, …), Sound, Chat, NPCs, Shared, and the server-only join or death handlers. Use Players:GetLocalPlayer() or the player global for the local player.

workspace / Workspace can look up existing Models and Parts by name (read-only). Tweens on those Parts are local visuals — other players do not see them. Use a server Script if everyone should see the change.