How would I go about "splitting" a textlabel so that I can have multiple words with custom properties all in one sentence?

To explain further, what I’m trying to achieve is basically this:


Notice how the 2nd sentence has the same properties (color font etc) except the very last word which is in a different color

!!!Before you reply with “use richtext”!!! , I already know that exists but I feel like it won’t help me very much since you’re limited to just changing the colors and font, you can’t add custom code JUST for that specific word

In undertale, for example, you could have some sentences like:
“I went” “THERE” ← And this word would start shaking and be in a completely different color “already”, all in one sentence, so id rather have some way to split the textlabel into more than 1 so i can custom code that specific word if needed

I hope i explained myself well enough and didn’t go onto too much of a tangent, and also if there’s ways to achieve this other than literally splitting the textlabel into multiple ones i’d be open to hear those too

1 Like

I think what people do is create a text label for each individual character and use some form of UI, like UI list or grid to lay them out, or some script math and then just apply the shake like you say, to the individual character.

I’ve never done it before tho, but from what I’ve heard and some working theory in my head I figure its probably something akin to this.

1 Like

Try using @Defaultio’s rich text module.

It has an example with shaking texts inside the module for reference.

1 Like

Yes you can.

local tempString = "This is a <b>%s</b> sentence!"

local formatted = string.format(tempString, "Wacky!")

That simple code will allow you to insert words, and in the case of that code exactly, this is what it’ll output: “This is a Wacky! sentence!”

Read up on it here: string | Documentation - Roblox Creator Hub

You cant customly SCRIPT* words in the sentence yourself
Mistyped that sentence my bad ill edit it

As in, yeah you can do that which I already know of but if i wanted to literally script the word “Wacky!” and make it shake or go transparent or whatever i want to code it im pretty sure that wont work since that only affects the string instance, not the textlabel itself which is the thing i want to code

Ill check it out tmrw

Characterlimit

string.split(txt," ")?
I dont understand what are you talking about.

This is relatively simple to achieve with a UIListLayout and UIAspectRatioConstraints, allowing for scaling with translation. You can ignore the Frame, which is literally named Frame, as it’s a set-size element I don’t want to scale dynamically with the text. Just generate the elements in order for each “word” and set their layout order to match that; you can even do specific letters if you wish or group them in the same frame and have it scale and change live!

I like this solution but the problem is that the words have different lengths, which makes each of the words look strange and not like they fit into a sentence together (unless i have to scale the textlabels myself according to each word’s length)

Nevermind turns out theres a property that does that for you (automaticsize) thanks a lot ill probably set this as the solution in a bit

1 Like

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