Attempt to concatenate Color3 with string

Attempt to concatenate Color3 with string
Script ‘Players.AxeI_c.PlayerGui.Chat.ChatFrame.Chat’, Line 35
Stack End - Studio

local NAME_COLORS =
	{
		Color3.new(253/255, 41/255, 67/255),
		Color3.new(1/255, 162/255, 255/255),
		Color3.new(2/255, 184/255, 87/255),
		BrickColor.new("Bright violet").Color,
		BrickColor.new("Bright orange").Color,
		BrickColor.new("Bright yellow").Color,
		BrickColor.new("Light reddish violet").Color,
		BrickColor.new("Brick yellow").Color,
	}

local function GetNameValue(pName)
	local value = 0
	for index = 1, #pName do
		local cValue = string.byte(string.sub(pName, index, index))
		local reverseIndex = #pName - index + 1
		if #pName%2 == 1 then
			reverseIndex = reverseIndex - 1
		end
		if reverseIndex%4 >= 2 then
			cValue = -cValue
		end
		value = value + cValue
	end
	return value
end

local color_offset = 0
local function ComputeNameColor(pName)
	return NAME_COLORS[((GetNameValue(pName) + color_offset) % #NAME_COLORS) + 1]
end

local ChatColor = ComputeNameColor(Player.Name)
newMessage.Text = [["<font color="rgb]] .. Color3.fromRGB(ChatColor) .. [[">]] .. "[" .. Player.Name .. "]:</font> " .. Message
newMessage.Text = [["<font color="rgb]] .. tostring(Color3.fromRGB(ChatColor)) .. [[">]] .. "[" .. Player.Name .. "]:</font> " .. Message

Just wrap the Color3 in a toString

1 Like

Hi thanks for your help it worked but the color is not applied. What am I doing wrong?

bug

Is RichText enabled on the TextLabel?

Yes, RichText is enabled on the TextLabel.

<font color="rgb(0, 0, 0)">[Axel_c]:</font> yes

Hello, text always appears black but must be white.

Why is it happening?

the text
the color

newMessage.TextColor3 = ComputeNameColor(Player.Name)
newMessage.Text =  "[" .. Player.Name .. "]: <font color=\"rgb(" .. tostring(Color3.new(ChatSettings.TextColor.Value)) .. ")\">" .. Message .. "</font>"
newMessage.Parent = CbatScrollingFrame

Color3.new returns a number between 0 and 1, you’d have to use Color3.fromRGB or multiply the R, G and B values by 255. You also have to have the R, G and B values to be an integer which can be achieved by using math.floor or math.ceil.

I used Color3.fromRGB and it didn’t work.

local r,g,b = math.floor(ChatSettings.TextColor.Value.R * 255), math.floor(ChatSettings.TextColor.Value.G * 255), math.floor(ChatSettings.TextColor.Value.B * 255)

newMessage.Text =  "[" .. Player.Name .. "]: <font color=\"rgb(" ..r..','..g..','..b.. ")\">" .. Message .. "</font>"
1 Like