A very overlooked Roblox feature: The random chat color (and the randomly colored clothing) which is given to each player when they create their account.
I’ve been interested in these for a bit of time now, but I can’t find anyone who has written a post about these. My question: How are they generated and is there a function that I can use to find the color of a player’s chat tag?
An example is below in case you don’t know what I’m talking about.
This is the method Roblox uses internally to get a player’s color from their username. You can put in the player’s name and you should get their color.
local 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("Bright yellow").Color,
}
local function GetNameValue(pName: string): number
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 function GetChatColor(name: string): Color3
return Colors[(GetNameValue(name) % #Colors) + 1]
end
print(GetChatColor("yourUsername"))
2 Likes
Thank you so much for the quick response! I will check out these resources.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.