So if you’re looking to add multiple colors to messages and i assume you want it to display when a player joins i can help!
- Add a
RemoteEvent
inReplicatedStorage
- Add a
Script
inServerScriptService
- Add a
Module Script
inside yourLocal Script
and name itChatColor
to make things easier
Inside your Script, add this to fire an event to the player when their character is added.
--<< Services >>--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--<< Variables >>--
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
--<< Code >>--
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
RemoteEvent:FireClient(player)
-- We fire this when the player's character loads because TextChatService isn't fully loaded when the player just joins
end)
end)
Inside your Local Script, add this! We’ll grab the ChatColor
module we created to make the DisplaySystemMessage
custom colors and we’ll create a function that’s called displayMessage
to connect to our RemoteEvent
and use OnClientEvent
. It’s your choice to choose between GeneralChannel
or SystemChannel
! You can learn more about these Default Channels here.
--<< Services >>--
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--<< Variables >>--
local ChatColor = require(script.ChatColor)
local GeneralChannel: TextChannel = TextChatService:FindFirstChild("RBXGeneral", true)
local SystemChannel: TextChannel = TextChatService:FindFirstChild("RBXSystem", true)
local RemoveEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
--<< Code >>--
local function displayMessage()
GeneralChannel:DisplaySystemMessage("I want the " .. ChatColor.Orange .. "orange" .. ChatColor.End .. " candy.")
end
RemoveEvent.OnClientEvent:Connect(displayMessage)
Inside your Module Script, add this! We will define each color in it’s rgb color value with RichText
and use Chat.End
to close it off and make it easier to manage.
--<< Example: '<font color="rgb(0,0,0)">' >>--
local ChatColor = {}
ChatColor.Orange = '<font color="rgb(255, 120, 0)">'
ChatColor.End = '</font>'
return ChatColor
The End Result should look like this:
Hopefully this helps in some way and can make you have a better understanding of it!