Client scripts
Client scripts run on each connected device with read-only world access and exclusive access to UI, Input and Effects.
Creating a client script
Set a script's Runs on property to Each player, or right-click in the Explorer and choose New Client Script. Each connected client runs its own instance of the script.
Available services
| Service | Purpose |
|---|---|
| Players | LocalPlayer and the connected player list. |
| UI | Windows, panels, widgets and on-screen messages. |
| Input | Keyboard and mouse events, mouse ray queries. |
| Effects | Screen flashes and translucent preview geometry. |
| Tools | Equipping tools and observing the held tool. |
| Remote | Named events to and from the server. |
| State | Read access to server-replicated values. |
| World | Read-only part lookup. |
| Teams | Read-only team lookup. |
| Build | Placement requests in Personal Servers. |
World access from client scripts is read only. Changes that affect other players must be requested from the server through Remote.
Parts on the client
World:FindFirstChild(name) returns a read-only part with these fields:
| Property | Description |
|---|---|
Name | Part name. |
Position | Center position. |
Size | Dimensions in studs. |
Color | Color3. |
Special | Lowercase Type, or nil. |
Bounds | Bounding box size of the part's shape. |
Teams on the client
| Member | Description |
|---|---|
Name, Color, Score | Read only. |
GetPlayerCount() | Number of players on the team. |
Example
local Players = game:GetService("Players")
local UI = game:GetService("UI")
local me = Players.LocalPlayer
UI:ShowMessage("Welcome, " .. me.Name .. "!", 3)