A lightweight Roblox module for sending system messages to one player, a subset of players, or every player — with optional RichText formatting — through the modern TextChatService API.
Free for use under the MIT License.
| File | Where to put it |
|---|---|
main.shared.luau |
ModuleScript named ChatMessageService inside ReplicatedStorage |
main.client.luau |
LocalScript inside a ScreenGui (ResetOnSpawn = false) inside StarterGui |
Also required: Create a
RemoteEventnamedClientMakeMessageas a direct child of theChatMessageServiceModuleScript.
After setup, usage is as simple as requiring the module from any Script or LocalScript:
local ChatMessageService = require(game
:GetService("ReplicatedStorage")
:WaitForChild("ChatMessageService"))
textaccepts any plain string or a valid Roblox RichText string (e.g.<b>Hello</b>,<font color="#FF0000">Alert</font>).
Call these from a server-sided Script.
ChatMessageService.Server:SpecifiedClient(client: Player, text: string): nilDisplays a system message in a single player's chat window.
| Precondition | client is a Player currently connected to the server. |
| Postcondition | The message is visible only to client; no other players see it. |
| Parameter | Type | Description |
|---|---|---|
client |
Player |
The player who receives the message. |
text |
string |
The message to display. |
Returns: nil
ChatMessageService.Server:SpecifiedClients(clients: {Player}, text: string): nilDisplays a system message in the chat window of each player in an array.
| Precondition | Every element of clients is a Player currently connected to the server. An empty array is a silent no-op. |
| Postcondition | Each player in clients sees the message; all others do not. |
| Parameter | Type | Description |
|---|---|---|
clients |
{Player} |
Array of players who receive the message. |
text |
string |
The message to display. |
Returns: nil
ChatMessageService.Server:AllClients(text: string): nilDisplays a system message in every connected player's chat window.
| Precondition | (none beyond the module being set up correctly) |
| Postcondition | All players currently in the server see the message. Players who join after this call do not receive it retroactively. |
| Parameter | Type | Description |
|---|---|---|
text |
string |
The message to display. |
Returns: nil
Call these from a LocalScript (client context).
ChatMessageService.Client:CurrentClient(text: string): nilDisplays a system message in the local player's chat window.
| Precondition | Must be called from a LocalScript. The RBXSystem TextChannel must exist (present in all standard Roblox experiences). |
| Postcondition | The message appears in the local player's chat window only. No other players see it. |
| Parameter | Type | Description |
|---|---|---|
text |
string |
The message to display. |
Returns: nil
-- Server Script
local ChatMessageService = require(game
:GetService("ReplicatedStorage")
:WaitForChild("ChatMessageService"))
-- Welcome a player when they join
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player: Player)
task.wait(1) -- brief buffer for the client listener to load
ChatMessageService.Server:SpecifiedClient(player,
string.format('<font color="#00FFCC"><b>[Welcome]</b></font> Hello, %s!', player.Name))
end)
-- Broadcast a global announcement
ChatMessageService.Server:AllClients('<font color="#FF5555"><b>[Alert]</b></font> Match starting in 30 seconds!')