Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to find a way to make typewriter/animated text start when visible using string.sub?

this is my script im trying to create a text that starts a typewriter effect when it turns visible using string.sub.yet it does not work and doesnt show the text so I wonder why.pls help;-;

local TextPlace = script.Parent 
local Text1 = script.Parent.Parent.Parent.TextZ.Value 
if TextPlace.Visible == true then
	for i = 1, Text1, 1 do
		script.Parent.Text = string.sub(Text1, 1, i)
		wait()
	end
end

2 answers

Well its way simpler then what you have done, the mistakes you have made is you added an extra 1 which is not needed and forgot the # try this

local TextPlace = script.Parent
local Text1 = script.Parent.Parent.Parent.TextZ.Value

for i = 1, #Text1 do
    if TextPlace.Visible then
    script.Parent.Text = string.sub(Text1, 1, i)
    wait(0.2) -- Adjust speed
end
end

(Not tested in studio might not be 100% accurate)

local TextPlace = script.Parent 
local Text1 = script.Parent.Parent.Parent.TextZ
if TextPlace.Visible == true 
	for i = 1,Text1.Value do
		TextPlace.Text = Text1.Value:sub(1,i)
		wait(0.01)
	end
end

I found numerous issues with the code. First of all, if you do Text1.Value as the variable its just going to be the value. It's not going to change when you change the value of Text1. I also modified the loop and fixed the wait(). It wasn't loading because since wait() is in an instant you didn't see anything since it's going super fast. Hope this helps

This discussion is preserved as it was. New answers, comments, and votes are closed.