How to make changeable chat tags

Hello!

I have just made an overhead gui system, which allows the player to equip different titles which they’ve unlocked (rookie, starter, pro, skilled, etc), and I want to introduce customer chat-tags which allows them to also show their title in the chat!

I’ve never worked with the chat service, nor chat-tags, so I’m looking for someone to help me with this! Anything helps, tutorials, scripts, videos, anything really!

Thanks!

2 Likes

I dont know much about chat tags either so…

1 Like

There’s many tutorials out there available for making chat tags that are changeable, which I’d advise looking up when you have the time.

I’d recommend starting with the TextChatService documentation provided by Roblox. You can use OnIncomingMessage to detect a message being recieved, like the post above mentions. You can use the TextSource feature to get the player who sent the message and apply the chat tag to each client.

If you want to make it customizable, I’d recommend using the Server to set attributes to the player with the string for the title.

An example of code I did for this would be:

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	local props = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		
		local title = player:GetAttribute("Title")
		local color_Code = player:GetAttribute("ColorCode")

		if title ~= nil and color_Code ~= nil then
			props.PrefixText = "<font color='#"..color_Code.."'>["..title.."]</font> " .. message.PrefixText
		end
	end

	return props	
end

I’m only offering an idea as this was the way I intend to go about it for my game, but there’s plenty of alternative, probably more efficient methods, of going about this.

1 Like