dxvblake
(blake)
December 9, 2023, 11:56pm
#21
oh wait, i put it in the wrong script
nvm still doesnt work, it just goes infinitely
function convertString(stringToConvert: string, colors)
local newString = stringToConvert
for keyword, newColor : Color3 in pairs(colors) do
newString = string.gsub(newString, '%f[%a]'.. keyword.. '%f[^%a]', '<font color="rgb('.. tostring(math.floor(newColor.R * 255)).. ','.. tostring(math.floor(newColor.G * 255)).. ','.. tostring(math.floor(newColor.B * 255)).. ')">'.. keyword.. '</font>')
end
return newString
end
local colors = {
['local'] = Color3.fromRGB(204, 0, 0),
['print'] = Color3.fromRGB(0, 229, 255)
}
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
local stringToConvert = script.Parent.Text
local newString = convertString(stringToConvert, colors)
script.Parent.Text = newString
end)
You would have to use a hex value instead of rgb and here is the correct format which I use along with rich text:
"<font color='#00FF00'>0</font>"
the zero inbetween the two arrows is the text and the quoted part with the hashtag before it is the hex. I don’t know how to get hexes without ColorHexa which is a color converter. Just enter the rgb number and it will give a hex value. Hope this helps!
dxvblake
(blake)
December 10, 2023, 12:04am
#23
that shouldnt matter if its just a color
dxvblake
(blake)
December 10, 2023, 2:04am
#24
have you found any fix for it yet?
@Mortai_Yt
savio14562
(savio14563)
December 10, 2023, 2:08am
#25
I use this whenever I need to highlight Luau code in game.
Mortai_Yt
(xM_MORT)
December 10, 2023, 3:17am
#26
im not really sure, don’t have too much time rn I might respond later though.
blvecoves
(blvecoves)
December 10, 2023, 6:19am
#27
You’d want to enable RichText
and go from there.
Click here to read about how to use rich text
1 Like