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

How can I get a specific letter of a variable?

I'm looking to take a variable and take the last few letters from it's contents, but doing the way you get a specific letter out of a string (("string",1,1)) doesn't work for a variable. Can someone tell me the syntax for doing that?

1 comment

0

print(string.sub("hello",2)) --> ello

1 answer

✓ Accepted answer

There is a table series called "string" (commonly used), to configure string values. In your case, you would want to use string.sub(target string,start of section number,end of section number). For example,

local var1 = "pineapple"
local var2 = string.sub(var1,5,7)
print(var2) --Should print "app"

3 comments

0

Note you could use Variable:sub(m,n) but that's not usually used.

0

That is very used wym it's not, it's even better than indexing the string table for sub

0

Its your opinion

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