Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I get a Player's Chat Color?

Hi. I'm making a custom chat GUI, and I want the Player's Name to be the same as their name would be with the normal ROBLOX chat system, but I need it to be a GUI. How would I get what color their name is? I have the GUI and everything, but I just can't get the Color.

2 comments

0

I remember seeing a file that someone had leaked; it contained an algorithm supposedly used by ROBLOX to generate the chat color from some properties of a Player's name. If I ever find it, I'll let you know. Otherwise, there is no direct way to access a Player's chat color.

0

On the roblox forums, there was a post (not sure if by or just he responded to it) but Quenty showed a working algorithm that found the players chat color

2 answers

local CHAT_COLORS =
{
	Color3.new(253/255, 41/255, 67/255), -- BrickColor.new("Bright red").Color,
	Color3.new(1/255, 162/255, 255/255), -- BrickColor.new("Bright blue").Color,
	Color3.new(2/255, 184/255, 87/255), -- BrickColor.new("Earth green").Color,
	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

script.Parent.TextColor3 = CHAT_COLORS[(GetNameValue(INSERT_USERNAME HERE) % #CHAT_COLORS) + 1]

Replace INSERT_USERNAME HERE with the username

In normal chat system it is found by using the Team Color. To make the gui you could do.

textgui.TextColor3=(game.Players.LocalPlayer.TeamColor).Color

Hope this helps. Might work, not positive

1 comment

0

If there are no teams, then it is not decided by team color

This discussion is preserved as it was. New answers, comments, and votes are closed.