So, I’m currently attempted to add Chat tags to my game, and I’m having a small problem where OnIncomingMessage only fires for the very first message (that being the “roblox translates all messages” message), and entirely stops working after.
I haven’t written anything wrong, have I?
function setTag(message, displayName, tag)
local tagData = rankList.Developer
message.PrefixText = string.format("[<font color='rgb(%d,%d,%d)'>%s</font>] %s",
tagData.TagColor.R * 255,
tagData.TagColor.G * 255,
tagData.TagColor.B * 255,
tagData.TagText,
displayName
)
end
TextChatService.OnIncomingMessage = function(message)
local properties = Instance.new("TextChatMessageProperties")
--// Below line purely for testing if the tags even work, they do.
setTag(properties, "SERVER", "Developer")
if message.TextSource then
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
local rankInGroup = player:GetRankInGroup(11598588)
if rankInGroup >= 254 then
setTag(properties, player.DisplayName, "Developer")
elseif rankInGroup == 253 then
setTag(properties, player.DisplayName, "Admin")
elseif rankInGroup == 252 then
setTag(properties, player.DisplayName, "Tester")
end
end
return properties
end