How to make sections of text appear in different colors?

So what I want to achieve is to make certain words in a text appear with another color. For example: “Hey could you give me those coins” where the word “coins” appears with the color yellow and the other words are just black. I know this is not a built-in function but I’ve seen games have this type of text.

Right now I use

local text = “Text here”

for i = 1, #text do
script.Parent.Text = string.sub(text,1,i)
end

I’ve seen people say that you should use a different text label for each word but that is a lot of work and I know it’s possible to script.

Does someone know how to achieve this?

1 Like

Unfortunately multiple text labels are the only way the achieve this currently. You could make an engine feature request for this provided it has not been made already.

1 Like

People have already asked about this feature if i’m right…

And I have seen this video where they did it but I don’t understand it…

@Defaultio wrote a really neat module that should suit your needs until Roblox gets around to implementing rich text.

Edit: For people still finding this thread, check out the native rich text system if you just need to change basic properties within a single text object. Nonetheless, the module above has more expressive features, such as inline images and entrance animations, that would be great for a dialogue system.

11 Likes

Damn, tried it out and it is AMAZING… Thnx for sharing it to me!

1 Like

Could you make a full documentation, of this module, please.
I don’t understand, what these functions are doing exactly.