Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Text slow typing effect ( Advance Scripting ) Help?

Asked by
14dark14 167
4 years ago
Edited 4 years ago

ok so I want TextLabel text sentence slowly type out like in those CSI movies you know where it types like a typewriter you know ok so that would look something like this

script.parent.text = "H"
wait(.1)
script.parent.text = "He"
wait(.1)
script.parent.text = "Hel"
wait(.1)
script.parent.text = "Hell"  
wait(.1)
script.parent.text = "Hello"

you get the idea but there has to be a more professional and better way of doing this I just can't think of anything that would work in this situation.

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Use string.sub() to piece up a String, join this within a generic for loop you can increment the character-max argument supplied to sub, and as well optionally supply a yield as all loops require.

local TextLabel = script.Parent

local TypeString = "Hello world!"

for Character = 1,#TypeString do wait(.5)
    TextLabel.Text = TypeString:sub(1,Character)
end 
2
Thanks! worked great, only thing is that you forgot to add a wait() for the for loop 14dark14 167 — 4y
1
If it worked, don't forget to mark it as an answer so other people know this question has been solved. killerbrenden 1537 — 4y
0
ok 14dark14 167 — 4y
1
Look at that. I literally just make an answer about yield requirements of iteration scopes.... this is just sad;) Ziffixture 6913 — 4y
Ad

Answer this question