How do I change Chat Tag when pressing a button?

Hi, so I’ve tried changing the Props when clicking a button, but when I chat, I have no tag at all.

-------------------- VARIABLES --------------------

local RS = game:GetService("ReplicatedStorage")
local Events = RS:WaitForChild("RemoteEvents")
local ManageTitle = Events:WaitForChild("ManageTitle")

local TextChatService = game:GetService("TextChatService")

local CurrentTitle = "Player"
local CurrentTitleColor = Color3.fromRGB(255,255,255)

-------------------- CHAT TAGS --------------------

ManageTitle.OnClientEvent:Connect(function(Title, TitleColor)
	CurrentTitle = Title
	CurrentTitleColor = TitleColor
    -- Does return "OWNER" and "ffffff"
end)

TextChatService.OnIncomingMessage = function(Message : TextChatMessage)
	local Props = Instance.new("TextChatMessageProperties")
	if Message.TextSource then
		local Player = Message.TextSource
		local UserID = Player.UserId
		Props.PrefixText = "<font color='#"..CurrentTitleColor:ToHex().."'>["..CurrentTitle.."]</font>"..Message.PrefixText -- Doesn't work
	end
end

The last line of code is giving a chat tag based on the “CurrentTitle” property, but when I chat in-game, I do not have a tag.

Thanks for help!

Hello there, I haven’t been in the studio for so long but hope my take on the topic helps!

You have to use the “return” keyword along with Props to get the intended result.

TextChatService.OnIncomingMessage = function(Message : TextChatMessage)
	local Props = Instance.new("TextChatMessageProperties")

	if Message.TextSource then
		local Player = Message.TextSource
		local UserID = Player.UserId
		Props.PrefixText = "<font color='#"..CurrentTitleColor:ToHex().."'>["..CurrentTitle.."] </font>"..Message.PrefixText
	end

    return Props
end
1 Like

Thank you so much for helping me!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.