I'm trying to get a sorta each letter at a time effect, is there a better way to do this?
txt.Text = "T"
wait()
txt.Text = "Ta"
wait()
txt.Text = "Tas"
wait()
txt.Text = "Tase"
wait()
txt.Text = "Taser"
I'm trying to get a sorta each letter at a time effect, is there a better way to do this?
txt.Text = "T"
wait()
txt.Text = "Ta"
wait()
txt.Text = "Tas"
wait()
txt.Text = "Tase"
wait()
txt.Text = "Taser"
With your code, you would have to change the entire thing if you had a different string.
local str = "Taser"
txt.Text = ""
for m in str:gmatch(".") do
txt.Text = txt.Text .. m
wait()
end
I first created a variable with the string "Taser", so you could change this later, and made sure txt did not have any text in it. Then, I made a loop that goes through each of the characters in str and adds that character to txt's text.
If you wanted to make it delete each character, you could do:
while #txt.Text >= 0 do
txt.Text = txt.Text:sub(1, -2)
wait()
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
6 comments
it works, thank god lol that would have taken forever
how would i make it go back, like so it would remove each letter until nothing?
If you don't know what gmatch is: http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation#string.gmatch
I don't understand
This seems more complicated than it should be. XP
What should it be?