If the title is a bit confusing, basically the code below that makes a GUI write words and erase them, but it keeps looping more than i want. how do i fix this?
TextNum = 1
function loop()
while true do
local text = script.Parent.Texts["Text"..TextNum].Value
local count = string.len(text)
for i = 1, count, 1 do
script.Parent.Label.Text = string.sub(text, 1, i)
wait(0.1)
end
wait(2)
for i = count, 0, -1 do
script.Parent.Label.Text = string.sub(text, 1, i)
wait(0.1)
end
TextNum = TextNum + 1
if not script.Parent.Texts:FindFirstChild("Text"..TextNum) then
wait(3)
TextNum = 1
end
return loop()
end
end
loop()
So the code above is from a model that works perfectly, it types some and then erases it and loops, but how do i break this code from outside of it like after a certain amount of times? I just have a question on how that works.

5 comments
No problem, remember to accept it as an answer if it works for you! Comment again if you have any questions.
why are you using string.len(text), use #text
sorry, was away. ive added an end and so im going to test it. sorry about the wait for reply.
kk
are you sure this works? I've added ends where it wouldn't register an 'end' and it still doesn't work.