Turn word into a number

Hello everyone! I´m trying to make a variable where a number of letters turn into a number. I have tried tonumber(textlabel.Text) and tostring(textlabel.Text) but both didn´t work. So please, can someone say how to do it and explain how it works. Thanks!

try printing textlabel.Text and see if its actually number as text because if it is then tonumber(text) would make it number

1 Like

You mean turning 1 to 1 or one to 1?

1 Like

Letter “one” has three letters. So one = 3

Oh then you can do #textlabel.Text to get the length of the text

1 Like

use #textlabel.Text

charssss

1 Like

Have a question, what does # mean?

# is the length operator in Lua.

1 Like

Basicly # is used to get length of string/arrays (tables)

so if you have lets say #{1,2,3,5} will return 4 since the length of table is 4

#string returns the length of string

1 Like

print(type(#textlabel.Text)) it should print number. If it does then you can do whatever you want with it.

1 Like

It works! The topic is now closed.

1 Like
print(string.len(textlabel.Text))

should work too I think

1 Like

Yes, string.len() will work too.

1 Like

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