[SOLVED] How do I color parts of text?

Hi, I am trying to make a sort of text editor in roblox. But to make things look better, I want to know how I can change different parts (words and numbers) into different colors. Like saying “if” would make the word if turn red. Is there a way to do this?

2 Likes

You can use RichText to achieve that.

1 Like

One more question, is there a way to make a new line when the user presses Enter? (Return) Because I really need that since a bunch of text editors have those.

Nevermind I got the answer.

1 Like

Can you share the answer here? A lot of people might read this down the road and need to know what you learned.

Using Rich Text you can use the formatting (like in html) to color, change font, and a bunch of other things. This is good since you wont have to change the entire text and can choose whatever you want changed. For example:

TextLabel.Text = '<font color="#FF005D">This is Red Text. </font>And this is white!'

Would make your text look like this:
image

13 Likes

correction:

TextLabel.Text = '<font color="#FF005D">This is Red Text.'.."</font>And this is white!"
1 Like

Richtext works for TextLabels and textboxes both.