Help with changing the nickname color when the message appears, please!

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	if not message.TextSource then return end
	
	local properties = Instance.new("TextChatMessageProperties")
	local bubbleProperties = Instance.new("BubbleChatMessageProperties")
			prefix = string.format("<font color='%s'>></font> ", color3ToHex(Color3.fromRGB(226, 140, 255)))
			message.Text = string.sub(message.Text, 4)
			
			bubbleProperties.BackgroundColor3 = Color3.new(0, 0, 0)
			bubbleProperties.TextColor3 = Color3.fromRGB(226, 140, 255)
			bubbleProperties.TextSize = 20

			TextChatService.OnBubbleAdded = function(message, adornee)
				return bubbleProperties
			end
		properties.PrefixText = prefix .. message.PrefixText
	return properties
end

I want all the text to be Color3.fromRGB(226, 140, 255), not just a prefix. But how??

1 Like

Here is the fixed script:

local textChatService = game:GetService("TextChatService")

textChatService.OnIncomingMessage = function(message: TextChatMessage)
	if not message.TextSource then return end
	local color = Color3.fromRGB(226, 140, 255):ToHex()
	
	local chatPrefix = `<font color="#{color}">%s</font>`
	
	local properties = Instance.new("TextChatMessageProperties")
	properties.PrefixText = string.format(chatPrefix, message.PrefixText)
	properties.Text = string.format(chatPrefix, message.Text)
	
	local bubble = Instance.new("BubbleChatMessageProperties")
	bubble.BackgroundColor3 = Color3.new()
	bubble.TextColor3 = Color3.fromHex(color)
	bubble.TextSize = 30
	
	textChatService.OnBubbleAdded = function() return bubble end

	return properties
end

It didn’t work because you forgot to put a hashtag before the hex color.

Here is an image of the code in action:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.