Split Text possible?

Hello Developers,
Is it possible to split a Text through different TextLabels?

Example 1: I wanna split “TEST”. So T would be TextLabel1, E would be TextLabel2, S would be TextLabel3 and T would be TextLabel4
DEVhelp

I could just do that manually but it doenst look good and it really takes time? Is there like a faster way with splitting text? Sorry for my laziness, but if i like want to split a sentence it would really take long.

What i mean is: Convert that one TextLabel into more different TextLabels is that possible?

If so, then i wanna make each of them rotate or do a function like transparency, position, tweenposition etc.

Example 2: TextLabel1.Rotation +30, TextLabel3.Rotation +30 and i wanna like leave the others dont mind them, so how do i rotate them? Should i just use script.TextLabel1.Rotation +30? If so, sorry for that dumb question, what is important to me is the Example 1 how to split the Text “TEST” into 4 TextLabels

I hope u understand and i would thank you!
Thank you for your patience!

3 Likes

You should use string.split

local SplitedText = string.split("TEST","") -- returns table

for _,v in SplitedText do
      print(v) -- will print T, E, S and T 
end

Yes! Just like that but in TextLabels, not print form, but that is what i mean!

local Last = 1
local Text = "TEST"
local Labels = {Label1, Label2, Label3, Label4}

for i = 4, 1, 1 do
    local Label = Labels[i]
    Last = i

    Label.Text = string.sub(Text, Last, i)
end

That should work for you! :grin:

(Just replace the table info with the TextLabel stuff, if yk what I mean, lol.)

Where do i parent the script? Should it be a LocalScript or an ServerScript?
Sorry for asking :joy:

And also will this create new textlabels or?

-- some text
local text = "TEST"

-- split the text into a table
local characters = string.split(text, "")

-- loop each character in the characters table
for i, character in ipairs(characters) do

    -- set the TextLabel to the character
    SplittedTextLabels["TextLabel" .. i].Text = character

end
2 Likes

LocalScript under wherever in your ScreenGui, as long as you set the “Labels” table to information like this:

{script.Parent.Label1, script.Parent.Label2, etc...}

Nope, you need the TextLabels! It will do the rest, though!

if you want something like that which procedurally generates text labels you might wanna look at text bounds or anything else that does the same thing and create text labels like that however having lots of text labels would also work

Sadly this isnt working, all textLabels are parented but there arent any changes

change the 1 in the step variable to -1

so the loop would be for i = 4, 1, -1… etc

Okay, try this: (LocalScript under the “SplittedTextLabels” folder!)

local Last = 1
local Text = "TEST"
local Labels = {script.Parent["TextLabel1 (T)"], script.Parent["TextLabel2 (E)"], script.Parent["TextLabel3 (S)"], script.Parent["TextLabel4 (T)"]}

for i = 1, 4, 1 do
    local Label = Labels[i]
    Last = i

    Label.Text = string.sub(Text, Last, i)
end

I will try this in like a few minutes, thanks for ur patience though :smile:

That would in theory work, however, it would loop backward. We would want it to loop forward, by doing this:

for i = 1, 4, 1 do
    
end

Here, it would start at one and increase in increments of one, until it reaches 4.

Hello there,
it works!! Great! But i do have one question, its not really what im looking for but its going in the right direction! I wanna make something like this

So i thought, that the text was splitted from one TextLabel to different TextLabels (like converting one textlabel to different textlabels) Does that work with a plugin or how do i make it look so smooth because it cannot be manually made by just adding thousand textlabels and i should like tween each of them so thats not currently what im looking for, but if u have another idea u can reply to this.

Yep, you’d have to tween them. I don’t know of any plugins to do this, but I’m sure you could find source code for it on the toolbox!

Yeah but how does it know which text it is like if its a player name u cant just add it manually. Is there any way possible in plugin or script form? Also im very sorry if i wasted your time!

Im a bit new to scripting i know the basics but ive never heard of bounds, may look into it tmrw.