I want to be able to get all characters before a certain index of a string. eg:
charsBeforeIndex("Stringy", 4) -- Returns "Stri"
I'm stumped on how to come about doing this. Help would be appreciated!!
I want to be able to get all characters before a certain index of a string. eg:
charsBeforeIndex("Stringy", 4) -- Returns "Stri"
I'm stumped on how to come about doing this. Help would be appreciated!!
Use string.sub.
print(string.sub("metatables",1,4)) -- prints 'meta'
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
string.sub will let you do this when provided a start+end index.
https://developer.roblox.com/en-us/api-reference/lua-docs/string
print(string.sub("Stringy",1,4))
something like that xd