Jump to content

Go letter by letter in a string.


Recommended Posts

local test = "hello" 
for i=1, #test do 
  outputChatBox(test:sub(i, 1)) 
end 

second parameter here is not the amount of characters, it is ending position.

this way it'll output only "h" and nothing after it.

string.sub(s, i [, j])

s:sub(i [,j])

Return a substring of the string passed. The substring starts at i. If the third argument j is not given, the substring will end at the end of the string. If the third argument is given, the substring ends at and includes j.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...