Chat coding: Working with tags and name colours?

I’d recommend that you use the SpeakerAdded event of ChatChannel to do this, as it guarantees that the speaker exists.

local Players = game:GetService("Players")
local ScriptService = game:GetService("ServerScriptService")
local ChatService = require(ScriptService.ChatServiceRunner.ChatService)

ChatService.SpeakerAdded:Connect(function(SpeakerName)
	local UserId = Players:FindFirstChild(SpeakerName).UserId
	local Speaker = ChatService:GetSpeaker(SpeakerName)
	if UserId == 20415935 then
		-- stuff
	elseif UserId == 558247746 then
		-- stuff
	end
end)
16 Likes