How do i color different words differently from the rest

so i’ve been trying to make roblox NPCs chat with TextChatService, and im trying to color their name differently from the rest of their text, but since roblox uses

'<mark><font color="rgb(numbers numbers numbers)">TEXT</font></mark>'

i cant put variables in, since the string is just set in stone
when i really want to do

"<mark><font color="..nameColors[math.fmod(getNameValue(Name),#nameColors-2)+1]..">"..Name.."</font></mark>"
1 Like

You can use `` (back apostrophe) thats like “” or ‘’ but you can insert variables using braces inside of it like {something}

local color = nameColors[math.fmod(getNameValue(Name), #nameColors - 2) + 1]
local text = `<mark><font color="{color:ToHex()}">{Name}</font></mark>`

this is using string interpolation ( ` backtick)

3 Likes

i’ve edited the code a little bit, but even before i edited it it still had this issue

image

why is there an extra <font color=“#d4d4d4” before the msg

edit: nvm i figured it out

OOPS i just realized i put ToHSV and not ToHex

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