I’m attempting to create chat tags based off a ModuleScript stored in ReplicatedStorage. The structure for the Tags module is as follows:
Tags
local Tags = {
[34103406] = {Tag = "LAWYER", TagColor = Color3.fromRGB(0, 85, 255), ChatColor = Color3.fromRGB(255, 183, 37)}
}
return Tags
My problem stems from me wanting to be able to apply specific group-based tags (see code below) layered over the tag configurations from the Tags module.
Code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local Tags = require(ReplicatedStorage:WaitForChild("Tags"))
TextChatService.OnIncomingMessage = function(Message: TextChatMessage)
local Player = Players:GetPlayerByUserId(Message.TextSource.UserId)
local Properties = Instance.new("TextChatMessageProperties")
local PropertiesTest = Instance.new("TextChatMessageProperties")
if Player:IsInGroup(5738308) then
Properties.PrefixText = string.format("<font color='#%s'></font> %s", Color3.fromRGB(30, 30, 30):ToHex(), "[SG]", Message.PrefixText)
end
if Tags[Player.UserId] then
local TagData = Tags[Player.UserId]
Properties.Text = string.format("<font color='#%s'>%s</font>", TagData.ChatColor:ToHex(), Message.Text)
Properties.PrefixText = string.format("<font color='#%s'>[%s]</font> %s", TagData.TagColor:ToHex(), TagData.Tag, Message.PrefixText)
end
return Properties
end
https://i.gyazo.com/a76c20870a528c1afe9bdc474c2610f3.mp4
I assume my problem has to do with the tags overwriting eachother but I can’t think of a solution that would allow both tags to work.
Any help would be appreciated.