---
title: "LocalScript"
description: "Public creator-authored Luau that runs on each Glorpia client."
canonical: "https://docs.glorpia.com/instances/localscript"
markdown: "https://docs.glorpia.com/instances/localscript.md"
---
# LocalScript

Public creator-authored Luau that runs on each Glorpia client.

**Category:** Instances

## Availability

| Name | Type | Description |
| --- | --- | --- |
| `Execution context` | client | Enabled LocalScripts run when they exist inside the local PlayerGui, local PlayerScripts, or the local Player's Character. |
| `Studio insertion` | available | Insert LocalScript anywhere in Explorer. Template or invalid locations remain inactive until a runnable runtime copy/context exists. |
| `Instance.new()` | supported | Instance.new("LocalScript") creates the hierarchy object. If it is enabled and enters a valid local runtime context, it starts once without restarting existing scripts. |
| `Enabled` | boolean | Read/write local hierarchy property. Enabling an unstarted LocalScript in a valid runtime context allows it to start on the next runtime script scan. |
| `script global` | available | Inside the script, script refers to that LocalScript instance. |

> **Note:** `LocalScript` uses the public client permission set. It does not receive the privileged permissions of `CoreLocalScript`.

## Starter templates and runtime copies

`StarterGui`, `StarterPlayerScripts` and `StarterCharacterScripts` are template locations. LocalScripts stored in those template trees do not execute there.

When the engine creates the local `PlayerGui`, `PlayerScripts` or Character, the corresponding LocalScript copies become runnable. Respawned character copies receive new runtime IDs and start once for that character.

## Client-only APIs

LocalScripts can use client APIs such as `UserInputService`, `RunService.RenderStepped`, `Players.LocalPlayer`, `workspace.CurrentCamera`, `RemoteEvent:FireServer()`, `RemoteEvent.OnClientEvent`, `RemoteFunction:InvokeServer()` and `RemoteFunction.OnClientInvoke`.

`ServerScriptService` and `ServerStorage` are server-only. Public LocalScripts cannot request or directly access those services.

`BasePart.Touched` is available to LocalScripts and is evaluated against that client's replicated/local world. Changes made by its LocalScript callback stay client-local unless the script explicitly sends data to the server through a RemoteEvent or RemoteFunction. Authoritative Humanoid mutations such as `Humanoid:TakeDamage()`, `Humanoid:MoveTo()`, `Humanoid:FollowPlayer()`, and writes to `Health`, `WalkSpeed` or `JumpPower` remain server-only.

## Example: client input

```luau
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

print("Running for", Players.LocalPlayer.Name)

UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Space then
        print("Space pressed on this client")
    end
end)
```

## Related

- [Public Scripts](https://docs.glorpia.com/scripting/public-scripts.md) — ServerScript and LocalScript execution and permission boundaries.
- [UserInputService](https://docs.glorpia.com/services/userinputservice.md) — Client keyboard and mouse input.
- [RunService](https://docs.glorpia.com/services/runservice.md) — Client and server frame signals.
- [RemoteEvent](https://docs.glorpia.com/instances/remoteevent.md) — Send one-way messages between LocalScripts and ServerScripts.
- [RemoteFunction](https://docs.glorpia.com/instances/remotefunction.md) — Invoke a callback on the other side and receive return values.
