Hi! So, I made this game and in the main menu there is a section that displays tips. It uses a typewriter effect to type it out, but for some reason I can’t seem to make a typewriter effect that will untype it.
If you want me to clarify on the subject don’t hesitate to ask.
local function typewrite(text)
textLabel.Text = text
for i = 1, #text do
textLabel.MaxVisibleGraphemes = i
task.wait(0.02)
end
textLabel.MaxVisibleGraphemes = -1
end
local function untypewrite()
for i = #textLabel.Text, 0, -1 do
textLabel.MaxVisibleGraphemes = i
task.wait(0.02)
end
textLabel.MaxVisibleGraphemes = -1
textLabel.Text = ""
end
I don’t know why you would need to untypewrite, but here.
Ok, unfortunately, I ran into an error. It still just disappears instead of typing itself backwards. I’m really sorry but I can’t mark your answer a solution due to that error.
local function untypewrite()
for i = string.len(textLabel.Text), 0, -1 do
textLabel.MaxVisibleGraphemes = i
task.wait(0.05)
end
textLabel.MaxVisibleGraphemes = -1
textLabel.Text = ""
end
Otherwise, the text just disappears after a few seconds.
You should use the # operator. It returns the length of tables and strings. string.len is most likely deprecated, or at least not used anymore. Sorry for forgetting to set the for loop increment to -1, I almost never use for loops that go backwards.