How do I fix Player Name repeating twice in Chat

Hey there everyone, recently I ran into a problem with this script where talking without a tag repeats your name twice
It looks like this:


this is set up so that your name color is dependent on your team color
It works completely fine when you have a tag like Owner or VIP
Here’s the code, a local script:

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local ChatWindowConfig = TextChatService.ChatWindowConfiguration

local gradient = Instance.new("UIGradient")
gradient.Color = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.fromRGB(252, 255, 94)), 
	ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 151, 24))
}
local ownergradient = Instance.new("UIGradient")
ownergradient.Rotation = 90
ownergradient.Color = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.fromRGB(134, 28, 255)), 
	ColorSequenceKeypoint.new(1, Color3.fromRGB(19, 0, 35))
}
local testergradient = Instance.new("UIGradient")
testergradient.Rotation = 90
testergradient.Color = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.fromRGB(41, 255, 26)), 
	ColorSequenceKeypoint.new(1, Color3.fromRGB(13, 255, 0))
}

local testers = {
...
}

local function GetTeamColorHex(plr)
	if plr and plr.Team then
		local c = plr.TeamColor.Color
		return string.format("#%02X%02X%02X",
			math.floor(c.R * 255),
			math.floor(c.G * 255),
			math.floor(c.B * 255)
		)
	end
	return "#FFFFFF"
end

TextChatService.OnChatWindowAdded = function(message)
	local props = ChatWindowConfig:DeriveNewMessageProperties()
	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		if not player then return props end

		local teamColor = GetTeamColorHex(player)
		local coloredName = string.format("<font color='%s'>%s:</font>", teamColor, player.DisplayName)

		if player:GetAttribute("isVIP") and player.UserId ~= 3369010010 then
			props.PrefixText = "[VIP]"
			props.Text = string.format("%s %s", coloredName, message.Text)
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			gradient:Clone().Parent = props.PrefixTextProperties

		elseif player.UserId == 33690100100 then
			props.PrefixText = "[OWNER]"
			props.Text = string.format("%s %s", coloredName, message.Text)
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			ownergradient:Clone().Parent = props.PrefixTextProperties

		elseif testers[player.UserId] then
			props.PrefixText = "[Tester🧪]"
			props.Text = string.format("%s %s", coloredName, message.Text)
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			testergradient:Clone().Parent = props.PrefixTextProperties

		else
			props.Text = string.format("%s %s", coloredName, message.Text)
		end
	end
	return props
end

Help would be greatly appreciated!

Have you tried:

props.PrefixText = ""
props.Text = string.format("%s %s", coloredName, message.Text)

still does the same problem ._30fe

take this :slight_smile:

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local ChatWindowConfig = TextChatService.ChatWindowConfiguration

local gradient = Instance.new("UIGradient")
gradient.Color = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.fromRGB(252, 255, 94)), 
	ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 151, 24))
}
local ownergradient = Instance.new("UIGradient")
ownergradient.Rotation = 90
ownergradient.Color = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.fromRGB(134, 28, 255)), 
	ColorSequenceKeypoint.new(1, Color3.fromRGB(19, 0, 35))
}
local testergradient = Instance.new("UIGradient")
testergradient.Rotation = 90
testergradient.Color = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.fromRGB(41, 255, 26)), 
	ColorSequenceKeypoint.new(1, Color3.fromRGB(13, 255, 0))
}

local testers = {
	...
}

local function GetTeamColorHex(plr)
	if plr and plr.Team then
		local c = plr.TeamColor.Color
		return string.format("#%02X%02X%02X",
			math.floor(c.R * 255),
			math.floor(c.G * 255),
			math.floor(c.B * 255)
		)
	end
	return "#FFFFFF"
end

TextChatService.OnChatWindowAdded = function(message)
	local props = ChatWindowConfig:DeriveNewMessageProperties()
	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		if not player then return props end

		-- local teamColor = GetTeamColorHex(player)
		-- local coloredName = string.format("<font color='%s'>%s:</font>", teamColor, player.DisplayName)

		if player:GetAttribute("isVIP") and player.UserId ~= 3369010010 then
			props.PrefixText = "[VIP]"
			props.Text = message.Text
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			gradient:Clone().Parent = props.PrefixTextProperties

		elseif player.UserId == 33690100100 then
			props.PrefixText = "[OWNER]"
			props.Text = message.Text
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			ownergradient:Clone().Parent = props.PrefixTextProperties

		elseif testers[player.UserId] then
			props.PrefixText = "[Tester🧪]"
			props.Text = message.Text
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			testergradient:Clone().Parent = props.PrefixTextProperties

		else
			props.Text = message.Text
		end
	end
	return props
end


this worked for me

		if player:GetAttribute("isVIP") and player.UserId ~= 3369010010 then
			props.PrefixText = `[VIP] {coloredName}`
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			gradient:Clone().Parent = props.PrefixTextProperties

		elseif player.UserId == 3369010010 then
			props.PrefixText = `[Owner] {coloredName}`
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			ownergradient:Clone().Parent = props.PrefixTextProperties

		elseif testers[player.UserId] then
			props.PrefixText = `[Tester🧪] {coloredName}`
			props.PrefixTextProperties = ChatWindowConfig:DeriveNewMessageProperties()
			testergradient:Clone().Parent = props.PrefixTextProperties

		else
			props.PrefixText = `{coloredName}`
		end

summary i replaced every props.Text = string.format()
with
props.PrefixText = [tag] {coloredName}