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 make a specific text have different color in a GUI?

I have tried string.color, but I realized that string.color isn't a thing anymore.

local TextLabel = script.Parent
TextLabel.Text = "Hello"
local TextToColor = string.find(TextLabel.Text, "He")
TextToColor.Color3 = Color3.new(1, 1, 1)

I want the "llo" part in "Hello" to be black, and the "He" part to be white, but it always prints this:

"TextLabel.LocalScript:4: attempt to index number with 'Color3'"

1 comment

0

Change the TextToColor.Color3 variable into TextToColor. That worked for me

2 answers

The easiest way to change color for your text is TextColor3

Here's a script for you.

script.Parent.Text = "Hello"
local TextToColor = string.find(TextLabel.Text, "He")
TextToColor.TextColor3 = Color3.new(1, 1, 1,)

1 comment

0

I put your script, and it says "TextLabel.LocalScript:4: attempt to index number with 'TextColor3' "

To change particular parts of text you need to use RichText, which you can enable on your TextButton/TextLabel/TextBox in the properties window. In order to make it a different color you would input something like so...

-- Turns 'He' red
script.Parent.Text = '<font color="rgb(255,0,0)">He</font>llo'

Your example...

script.Parent.Text = '<font color="rgb(255,255,255)">He</font><font color="rgb(0,0,0)">llo</font>'

2 comments

0

Let me try that give me a second

0

It doesn't work i tried the Richtext property on and off with the script and without rich text the textlabel said "'Hello'" and with the richtext all it did was just say hello and nothing else the colors didn't work

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