tahu157
|
  |
| Joined: 16 Nov 2008 |
| Total Posts: 15045 |
|
|
| 02 Jan 2016 11:11 AM |
So say I had a string of text that I want to put in a TextLabel, how would I get it to add one letter at a time?
E.g:
T Th Thi This This i This is This is t This is te This is Tex This is Text
I know I can do something like this:
TextLabel.Text = "T" wait (0.1) TextLabel.Text = "Th"
and so on until I get the full message. But is there a way to get that same effect without writing the same thing over and over and over again with one letter added each time? |
|
|
| Report Abuse |
|
|
heirIoom
|
  |
| Joined: 15 Jul 2012 |
| Total Posts: 3775 |
|
|
| 02 Jan 2016 11:27 AM |
local text = "Let us continue on. "
local frame = script.Parent.Parent local text1 = script.Parent
local sound = Instance.new("Sound",workspace) sound.SoundId = "http://www.roblox.com/asset/?id=14863866" sound.Pitch = 1 sound.Volume = 0.5
for i = 1,string.len(text),1 do sound:play() text1.Text = string.sub(text,1,i) wait(.5) end wait(1.5) |
|
|
| Report Abuse |
|
|
tahu157
|
  |
| Joined: 16 Nov 2008 |
| Total Posts: 15045 |
|
|
| 02 Jan 2016 11:33 AM |
Awesome, thank you. I was sort of headed in that direction:
local msgs = {"This", "is", "a", "test"}
while (true) do wait (0.1) print "Stuff" script.Changer.Value = script.Changer.Value + 1 script.Parent.Text = script.Parent.Text..msgs[script.Changer.Value] end
Wasn't quite there though. |
|
|
| Report Abuse |
|
|
ByDefault
|
  |
| Joined: 25 Jul 2014 |
| Total Posts: 3197 |
|
|
| 02 Jan 2016 12:42 PM |
Much shorter
local s = "This is the string"
for = 1,string.len(s) do print(string.sub(s,1,i)) end |
|
|
| Report Abuse |
|
|
heirIoom
|
  |
| Joined: 15 Jul 2012 |
| Total Posts: 3775 |
|
|
| 03 Jan 2016 06:50 AM |
@ByDefault Only difference is myn plays a sound on each letter. |
|
|
| Report Abuse |
|
|
tahu157
|
  |
| Joined: 16 Nov 2008 |
| Total Posts: 15045 |
|
|
| 03 Jan 2016 09:23 AM |
| It's also missing the i in the for statement and a wait statement, without which the game crashes. |
|
|
| Report Abuse |
|
|