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

How do I get the first character in a string?

I want to get just he first character in a string

string = "Hello"

print(string[1])
print(string:sub(1))
print(string.sub(1))

None of these worked.

1 comment

0

DevArk is correct but a quicker way to call it is: print(string:sub(1,1))

1 answer

✓ Accepted answer

Well "string" is a keyword used by lua i recommend not making a variable called that try something like str?

print(string.sub(str, 1,1))

1 comment

0

Good answer, but next time try to put your code in a code block. :)

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