function text(txt)
for i = 1, #txt do
script.Parent.Text.Text = string.sub(text, 1, i)
wait()
end
end
text("yo gang")
I know whats wrong I just don't know a good way of fixing it
function text(txt)
for i = 1, #txt do
script.Parent.Text.Text = string.sub(text, 1, i)
wait()
end
end
text("yo gang")
I know whats wrong I just don't know a good way of fixing it
You are putting the function "text" under the parameters of string.sub. To fix this, simply change the parameters to "txt" instead.
Also, to get the length of a text, I believe you must do string.len(txt) rather than #txt, for "#" returns the number of values inside a table.
Thus, the code should look like this:
local function text(txt)
for i = 1, string.len(txt) do
script.Parent.Text.Text = string.sub(txt, 1, i)
wait()
end
end
text("yo gang")
Hope this helps! Message me with any problems you may have :)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
You are absolutely wrong. The length operator works for strings as well. It returns the length of the string.
Okay, well that’s easily fixable. Did this fix your function though?