---
title: "Public Scripts"
description: "Creator ServerScripts and LocalScripts with separate authoritative-server and client permission sets."
canonical: "https://docs.glorpia.com/scripting/public-scripts"
markdown: "https://docs.glorpia.com/scripting/public-scripts.md"
---
# Public Scripts

Creator ServerScripts and LocalScripts with separate authoritative-server and client permission sets.

**Category:** Scripting

## Execution

| Name | Type | Description |
| --- | --- | --- |
| `ServerScript` | server | Enabled ServerScripts under Workspace or ServerScriptService start once when discovered by the authoritative server. |
| `LocalScript` | client | Enabled LocalScripts start once inside the local PlayerGui, local PlayerScripts or the local Player's Character. |
| `CoreScript / CoreLocalScript` | engine only | Glorpia-owned privileged scripts. Creator scripts do not receive core permissions. |
| `script` | global | Inside either public script class, script refers to the currently running script Instance. |

> **Note:** StarterGui, StarterPlayerScripts and StarterCharacterScripts are templates. LocalScripts do not execute from those template trees; their runtime copies start after they are cloned into PlayerGui, PlayerScripts or the local Character.

## Client and server permissions

| Name | Type | Description |
| --- | --- | --- |
| `UserInputService` | LocalScript | Client keyboard, mouse and cursor APIs. Requesting it from a public ServerScript is rejected. |
| `RunService.RenderStepped` | LocalScript | Client render-frame signal. Public ServerScripts cannot connect to it. |
| `Players.LocalPlayer` | LocalScript | The current client Player. It is nil in public ServerScripts. |
| `workspace.CurrentCamera` | LocalScript | The current client Camera. Public ServerScripts see no CurrentCamera. |
| `ServerScriptService / ServerStorage` | ServerScript | Server-only services. Public LocalScripts cannot request or directly access them. |
| `loadstring()` | ServerScript | Disabled by default. Available only when ServerScriptService.LoadStringEnabled is enabled in Studio. LocalScripts cannot use it. |
| `Workspace / Players / Lighting / ReplicatedStorage / TweenService` | both | Documented shared services available in both public contexts. |
| `BasePart.Touched` | both | ServerScripts receive authoritative contacts. LocalScripts receive contacts from the client's replicated/local world, and callback changes stay local unless explicitly sent to the server. |
| `Humanoid Health / WalkSpeed / JumpPower writes` | ServerScript | LocalScripts may read replicated values but cannot mutate these authoritative properties. |
| `ServerScript.Enabled writes` | ServerScript | Public LocalScripts cannot change a ServerScript's Enabled property. LocalScript Enabled changes stay client-local. |
| `Humanoid:TakeDamage()` | ServerScript | Authoritative damage is server-only. Humanoid.Died remains observable on both sides. |
| `Humanoid:MoveTo()` | ServerScript | Authoritative NPC movement targets are server-only. |
| `Humanoid:FollowPlayer()` | ServerScript | Continuous authoritative NPC following is server-only. |

`Glorpia.IsServer`, `Glorpia.IsClient`, `RunService:IsServer()` and `RunService:IsClient()` report the actual side of the current runtime.

## Studio

Explorer can insert `ServerScript`, `LocalScript`, `RemoteEvent` and `RemoteFunction`. Double-clicking either script class opens the same editable public script tab.

Autocomplete follows the selected script type: server-only services and remote members are hidden in LocalScripts when unavailable, while client-only input, `RenderStepped`, `LocalPlayer` and client remote members are hidden in ServerScripts.

Signal members such as `Touched`, `Activated`, `MouseButton1Click`, `MouseButton1Down` and `MouseButton1Up` are completed as `:Connect()` calls with the caret placed inside the parentheses.

## RemoteEvent

```luau
-- LocalScript
local event = game.ReplicatedStorage:WaitForChild("ActionEvent")
event:FireServer("JumpButton")
```

```luau
-- ServerScript
local event = game.ReplicatedStorage:WaitForChild("ActionEvent")

event.OnServerEvent:Connect(function(player, action)
    print(player.Name, action)
    event:FireClient(player, "Accepted")
end)
```

Use `FireAllClients(...)` to broadcast from the server. LocalScripts receive server messages through `OnClientEvent`.

## RemoteFunction

```luau
-- ServerScript
local getRound = game.ReplicatedStorage:WaitForChild("GetRound")
getRound.OnServerInvoke = function(player)
    return 3, "Playing"
end
```

```luau
-- LocalScript
local getRound = game.ReplicatedStorage:WaitForChild("GetRound")
local round, state = getRound:InvokeServer()
print(round, state)
```

ServerScripts can use `InvokeClient(player, ...)` with a client's `OnClientInvoke` callback.

## Shared creator APIs

Both public script contexts use the documented hierarchy API, datatypes, task/math helpers, supported Instances and shared services. `Instance.new()` supports script objects, GUI objects, Lighting effects, Humanoid, RemoteEvent, RemoteFunction, BasicSound, Parts, values and containers.

Server-side world changes remain authoritative and replicate through the supported network state. LocalScript-only changes remain client-local unless sent to the server through a RemoteEvent or RemoteFunction.

## Script output

`print(...)` writes Information and `warn(...)` writes Warning. During Studio Play, output from the client runtime is marked `CLIENT`.

## Related

- [ServerScript](https://docs.glorpia.com/instances/serverscript.md) — Authoritative creator script class.
- [LocalScript](https://docs.glorpia.com/instances/localscript.md) — Client creator script class.
- [RemoteEvent](https://docs.glorpia.com/instances/remoteevent.md) — One-way client/server communication.
- [RemoteFunction](https://docs.glorpia.com/instances/remotefunction.md) — Request/response client/server communication.
- [ReplicatedStorage](https://docs.glorpia.com/services/replicatedstorage.md) — Shared hierarchy for remotes and other supported instances.
- [UserInputService](https://docs.glorpia.com/services/userinputservice.md) — Client-only public input API.
- [RunService](https://docs.glorpia.com/services/runservice.md) — Client and server frame signals.
- [ServerScriptService](https://docs.glorpia.com/services/serverscriptservice.md) — Server-side script container.
- [ServerStorage](https://docs.glorpia.com/services/serverstorage.md) — Server-only stored hierarchy.
