Help with string.sub

I am currently trying to make this NPC talk system, where the letters appear 1 by 1, for this I am using
string.sub.
But I have run into an issue with it, right now I am printing “Hello world” letter by letter in the output but when it comes to space, it cant print it because it is nil, how would I go around this?

Thanks in advance

Are you talking about a literal space character? A space is still a space, not nil. Could you show your code?

Oops, i’ve looked back at my code and i made a mistake with my loops, its working now so ill just mark your comment as solution

the problem was i did 2 for i loops and used the wrong i variable if that makes sense

1 Like
string.sub()

it is a function that can create a smaller string of the inputted string that starts at I and ends at J.

for a typewriter effect, this is an example:

for i = 1, string.len(text here), 1 do
      textObject.Text = string.sub(text, 1, i)
      task.wait()
end

this is not an efficient approach, as it does not support RichText or auto translations.

You can learn more about this in the Official Lua Website

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.