Hello, I’ve been encountering issue with duplication of chat message in text chat (it doesn’t affects bubble chat)
When I’m trying to send a message, it duplicates it when my script should replace it instead
-- Chat
local Users = require(ReplicatedStorage.Modules:WaitForChild("GameManager").Users)
TextChatService.OnIncomingMessage = function(message: TextChatMessage)
local properties = Instance.new("TextChatMessageProperties")
if message.TextSource then
local player = game.Players:GetPlayerByUserId(message.TextSource.UserId)
-- checks if user is in table
if Users[player.UserId] then
properties.PrefixText = "<font color='" .. Users[player.UserId].RankColor .. "'>" .. Users[player.UserId].Rank .. "</font> " .. message.PrefixText .. "<font color='" .. Users[player.UserId].RankTextColor .. "'> " .. message.Text .. "</font>"
end
print(message.PrefixText .. message.Text)
end
return properties
end
If I’m not clear enough - I’m trying to change text color of the player, and I achieved it, but it also sends original message too, I can’t understand what should I even do to prevent it
I have a modules inside of script that handles chat prefixes, it returns this
Name of module is group rank
return {
Color = "#0000ff",
Name = "Tester"
}
And how I add prefix to player’s name
TextChatService.OnIncomingMessage = function(message)
if not message.TextSource then return end
local newMessageProperties = Instance.new("TextChatMessageProperties")
local User = message.TextSource.UserId
local Player = Players:GetPlayerByUserId(User)
-- I dont think you need vip one
--[[local OwnsVip = CheckOwnedGamepass(Player, 860504971)
if OwnsVip then
newMessageProperties.PrefixText = "<font color = '".. AllTags["VIP"]["Color"] .."'>[".. AllTags["VIP"]["Name"] .."] </font>" .. message.PrefixText
end]]
local PlrGroupRank = tostring(Player:GetRankInGroup(34319502))
if AllTags[PlrGroupRank] then
newMessageProperties.PrefixText = "<font color = '".. AllTags[PlrGroupRank]["Color"] .."'>[".. AllTags[PlrGroupRank]["Name"] .."] </font>" .. message.PrefixText
end
return newMessageProperties
end
AllTags is table containing all modules inside this script (I mentioned how they look above and their name too)
Your script affects only what is before message (prefix), and doesn’t touch the part of the message itself, I guess my best I can do is just not to color the message