Chat¶
System · Chat · server and client scripts
Chat sends player chat messages, posts system announcements, shows chat bubbles, runs server slash commands and delivery filters, and fires signals when chat events arrive.
MaxLength¶
MaxLength is the longest chat message, system announcement, or chat bubble in bytes (200).
Example
Send¶
Send sends a chat message as the local player. Only client scripts may call it. Blank strings are ignored; strings longer than MaxLength bytes or containing NUL bytes raise an error.
Errors (1)
| Error | When |
|---|---|
Send can only be called from a client script |
Called from a server script. |
Announce¶
Announce delivers a system announcement without running the chat safety filter. Blank strings are ignored; strings longer than MaxLength bytes or containing NUL bytes raise an error. Pass options.Color as a Color with finite channels in 0..1 to tint the announcement.
On the server, pass options.To as a player or a list of players (omit it to reach everyone; an empty list {} sends to nobody). On a client, Announce fires Announced locally and rejects options.To.
Announced¶
Announced fires on clients with (text, color) for each system announcement and engine notice (color is nil for engine notices and announcements sent without options.Color).
Errors (1)
| Error | When |
|---|---|
Announced can only be written from a client script |
Written from a server script. |
MessageSent¶
MessageSent fires on both the server and clients with (player, text, color) after a player's chat message passes the safety filter, where color is the player's name color.
Example
Command¶
Command registers a slash command and returns a Connection. When a player sends /name args, the server calls handler(player, args) with the text after the first run of spaces or tabs and does not broadcast the message or fire MessageSent. Command matching ignores ASCII letter case, and any unregistered /word message relays as ordinary chat.
name must be 1 to 32 ASCII letters, digits, _, or -, without a leading /. Registering a name that is already registered raises an error. Calling :Disconnect() or stopping or reloading the owning script removes the command.
Example
Errors (1)
| Error | When |
|---|---|
Command can only be called from the server |
Called from a client script. |
SetDelivery¶
SetDelivery installs a recipient filter for chat messages after the safety filter runs and returns a Connection. Only one delivery hook is active at a time; calling SetDelivery again replaces the previous hook. Calling :Disconnect() or stopping or reloading the owning script restores delivery to everyone.
The hook runs as fn(sender, text) without yielding and returns true (every player), false (nobody), or a list of player entities. A hook that yields, raises an error, or returns another value drops the message. Server MessageSent still fires for every message that passes the safety filter, even when the hook drops it.
Errors (1)
| Error | When |
|---|---|
SetDelivery can only be called from the server |
Called from a client script. |
ShowBubble¶
ShowBubble displays a chat bubble above an entity without running the chat safety filter. Passing a player targets that player's character and does nothing when the player has no character; any other entity must have a Position. Blank strings are ignored; strings longer than MaxLength bytes or containing NUL bytes raise an error.
On the server, ShowBubble broadcasts the bubble to clients. On a client, it fires BubbleShown locally.
BubbleShown¶
BubbleShown fires on clients with (entity, text) for each ShowBubble call and for each received player chat message whose speaker has a character.
Example
Errors (1)
| Error | When |
|---|---|
BubbleShown can only be written from a client script |
Written from a server script. |
Filter¶
Filter runs player-authored text through the chat safety filter and yields until it answers, returning (status, filteredText). status is "Ok", "Rejected", "RateLimited", "Unavailable", or "TimedOut". Only "Ok" returns filtered text; every other status returns nil.
Pass options.Timeout as a finite number of seconds above 0 (10 by default). Each player has a dedicated filter bucket of 10 tokens refilling at 5 per second; calling Filter when the bucket is empty returns ("RateLimited", nil) immediately. In local test mode with no backend configured, Filter returns ("Ok", text) immediately.
Example
Errors (1)
| Error | When |
|---|---|
Filter can only be called from the server |
Called from a client script. |