💬 Chat
Configure, send and intercept chat messages
🎒 Examples
Chat.BroadcastMessage("Welcome to the server!")
Events.SubscribeRemote("MyChatSubmit", function(player, message)
if (not Chat.Submit(player, message)) then
Chat.SendMessage(player, "Your message was not sent")
end
end)
Colors in Chat
It is also possible to send colored messages in the Chat! For that, just circumvent a piece of text with a style tag: \<TAG>my awesome text</>.

Chat.BroadcastMessage("Hello with <cyan>Cyan</> text message!")
All supported text styles/tags:
\<cyan> \<green> \<blue> \<purple> \<marengo> \<yellow> \<orange> \<red> \<grey> \<bold> \<italic>
It is NOT possible to combine two or more styles together (e.g. \<bold> + \<red>).
🗿 Static Functions
AddMessage | Adds a chat message which will display local only | |
BroadcastMessage | Sends a chat message to all Players | |
Clear | Clears all messages | |
SendMessage | Sends a chat message to a Player only | |
SetConfiguration | Configures the Chat visuals and position | |
SetVisibility | Sets if the Chat is visible or not | |
Submit: boolean | Submits a chat message as if the Player had typed it in the chat | |
Subscribe: function | Subscribes to an Event | |
Unsubscribe | Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback |

AddMessageModerate
Adds a chat message which will display local only
Chat.AddMessage(message)
Parameters
| Name | Type | Descrição |
|---|---|---|
message | string | The message, supports the same rich text tags as the chat |

BroadcastMessageModerate
Sends a chat message to all Players
Chat.BroadcastMessage(message)
Parameters
| Name | Type | Descrição |
|---|---|---|
message | string | The message to send to all Players |
Examples (1)
Chat.BroadcastMessage("Welcome to the server!")

SetConfigurationModerate
Configures the Chat visuals and position
Chat.SetConfiguration(screen_location?, size?, anchors_min?, anchors_max?, alignment?, justify?, show_scrollbar?)
Parameters
| Name | Type | Descrição |
|---|---|---|
screen_location? | Vector2D | Screen location, or the left and top offsets when the anchors are stretched Default Vector2D(-25, 0) |
size? | Vector2D | Size, or the right and bottom offsets when the anchors are stretched Default Vector2D(600, 250) |
anchors_min? | Vector2D | Min anchor, from (0, 0) top-left to (1, 1) bottom-right Default Vector2D(1, 0.5) |
anchors_max? | Vector2D | Max anchor, from (0, 0) top-left to (1, 1) bottom-right Default Vector2D(1, 0.5) |
alignment? | Vector2D | Pivot of the chat, (0.5, 0.5) is the center Default Vector2D(1, 0.5) |
justify? | boolean | Whether the text is justified Default true |
show_scrollbar? | boolean | Whether to show the scrollbar Default true |

SetVisibilityOptimal
Sets if the Chat is visible or not
Chat.SetVisibility(is_visible)
Parameters
| Name | Type | Descrição |
|---|---|---|
is_visible | boolean | Whether the Chat is visible or not |

SubmitModerate
Submits a chat message as if the Player had typed it in the chat
It also triggers the PlayerSubmit event
local ret = Chat.Submit(player, message)
Parameters
| Name | Type | Descrição |
|---|---|---|
player | Player | The player who is sending the message |
message | string | The message |
Returns
| Type | Descrição |
|---|---|
| boolean | false if a PlayerSubmit handler cancelled the message, true if it was broadcast |
Examples (1)
Events.SubscribeRemote("MyChatSubmit", function(player, message)
if (not Chat.Submit(player, message)) then
Chat.SendMessage(player, "Your message was not sent")
end
end)

SubscribeOptimal
Subscribes to an Event
local ret = Chat.Subscribe(event_name, callback)
Parameters
| Name | Type | Descrição |
|---|---|---|
event_name | string | Event to subscribe to |
callback | function | Callback to run on the event occurring |
Returns
| Type | Descrição |
|---|---|
| function | The function callback |

UnsubscribeOptimal
Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Chat.Unsubscribe(event_name, callback?)
🚀 Events
ChatEntry | Called when a new Chat Message is received, this is also triggered when new messages are sent programatically | |
Close | When player closes the Chat | |
Open | When player opens the Chat | |
PlayerSubmit | Called when a player submits a message in the chat |

ChatEntry
Called when a new Chat Message is received, this is also triggered when new messages are sent programatically
This is useful for creating your own Chat interface while still use the built-in system
Chat.Subscribe("ChatEntry", function(message, player)
-- ChatEntry was called
end)

PlayerSubmit
Called when a player submits a message in the chat
Chat.Subscribe("PlayerSubmit", function(message, player)
-- PlayerSubmit was called
return true
end)
Arguments
| Name | Type | Descrição |
|---|---|---|
message | string | The message sent by the player |
player | Player | The player who sent the message - on client it will always be the localplayer |
Returns
| Type | Descrição |
|---|---|
| boolean | Return false to prevent the message from being sent |

