How I can make player chat tag system without changing chatservice version

  1. **I made a tag system for players but it needs to change chat service version to work

  2. **Roblox going to remove legacyChatService so I need to use it on normal version

-- --[[SETTINGS]]--
local dataManager = require(game.ServerScriptService:WaitForChild("ProfileFolder")._ProfileManager)

-- Define tags with both the text and the color
local tagPrefixes = {
	Bot = {text = "Bot", color = Color3.fromRGB(0, 255, 255)}, -- Cyan
	Hacker = {text = " Hacker", color = Color3.fromRGB(20, 148, 20)}, -- Green
	ExPresident = {text = "Ex-President", color = Color3.fromRGB(255, 223, 0)}, -- Yellow
	Froigner = {text = "Froigner", color = Color3.fromRGB(255, 255, 255)}, -- White
	Yakuza = {text = "Yakuza", color = Color3.fromRGB(136, 8, 8)}, -- Red
	Saiyan = {text = "Saiyan", color = Color3.fromRGB(0, 255, 255)}, -- Light Blue
	Salty = {text = "Salty", color = Color3.fromRGB(255, 255, 255)}, -- White
	Gambler = {text = "Gambler", color = Color3.fromRGB(1, 68, 33)}, -- Dark Green
	GrassEnjoyer = {text = "Grass Enjoyer", color = Color3.fromRGB(123, 179, 105)}, -- Grass Green
	Curse = {text = "Curse", color = Color3.fromRGB(48, 25, 52)}, -- Dark Purple
	HonoredOne = {text = "Honored One", color = Color3.fromRGB(255, 255, 0)}, -- Gold
	Senator = {text = "Senator", color = Color3.fromRGB(255, 255, 0)}, -- Gold
	Son = {text = "Son] [We saiyans have no limit ", color = Color3.fromRGB(136, 8, 8)}, -- Red + Light Blue
	Fool = {text = "Fool", color = Color3.fromRGB(149, 165, 166)}, -- Grey
}

--[[TAG SETUP FUNCTION]]--
local function SetupTags()
	spawn(function()
		local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

		-- Tag validity checker
		local Tags = {
			['CheckValidity'] = function(Player)
				if not Player then return end
				local profile = dataManager.Profiles[Player]

				-- Check if the player's name is "Yduh981"
				if Player.Name == "Yduh981" then
					-- If the player's name matches, assign them the Fool tag
					return {
						--[[Chat Tag]]--
						{
							TagText = tagPrefixes.Fool.text,
							TagColor = tagPrefixes.Fool.color -- Apply the unique color here
						},
						--[[PlayerName Colour]]
						Color3.fromRGB(255, 255, 255) -- Default name color (can be adjusted per tag if needed)
					}
				end

				if profile then
					local equippedTag = profile.Data.EquippedTag
					local tagInfo = tagPrefixes[equippedTag] -- Get the tag information (text and color)

					-- If the tag is not nil, return the tag data
					if tagInfo then
						return {
							--[[Chat Tag]]--
							{
								TagText = tagInfo.text,
								TagColor = tagInfo.color -- Apply the unique color here
							},
							--[[PlayerName Colour]]
							Color3.fromRGB(255, 255, 255) -- Default name color (can be adjusted per tag if needed)
						}
					end
				end

				-- If the tag is nil, return nil so no tag is applied
				return nil
			end,
		}

		ChatService.SpeakerAdded:Connect(function(PlayerName)
			local speaker = ChatService:GetSpeaker(PlayerName)
			local Player = game:GetService("Players")[PlayerName]

			local function UpdatePlayerTag()
				local TagData = nil
				local NameColourData = nil

				-- Check tag validity
				local Data = Tags['CheckValidity'](Player)
				if Data then
					TagData = Data[1]
					NameColourData = Data[2]
				end

				if TagData then
					if NameColourData then
						speaker:SetExtraData("NameColor", NameColourData)
					end
					speaker:SetExtraData("Tags", { TagData })
				else
					-- If no tag data is found, make sure no tags are set
					speaker:SetExtraData("Tags", {})
				end
			end

			-- Update tag when player chats
			local MessageCount = 0
			local UpdateEvery = 2
			Player.Chatted:Connect(function()
				if MessageCount >= UpdateEvery then MessageCount = 0 
					UpdatePlayerTag()
				elseif MessageCount == 0 then 
					UpdatePlayerTag()
				end
				MessageCount = MessageCount + 1
			end)
		end)
	end)
end

-- Player added function
game:GetService("Players").PlayerAdded:Connect(function(Player)
	local ChatTagStorage = Instance.new("Folder")
	ChatTagStorage.Name = "ChatTagStorage"
	ChatTagStorage.Parent = Player
end)

-- Initialize the tag system
SetupTags()

You can use the port I made of LegacyChat

You’ll have to change how you get ChatService by instead using

local Chat = require(game.ReplicatedStorage.Chat)
local ChatService = Chat:GetChatService() -- Finding the module under Chat also works, but this is something I added that is simpler

If you put the chat inside of replicated storage (which is what is recommended)

Everything else should work as it used to


You can also apply chat tags to the default TextChatSerivce UI by using .OnIncomingMessage event, and returning a TextChatMessageProperties to which you’ve set the PrefixText property. Color is applied through rich text

1 Like

Thank you so much it works well now.

1 Like