The title explain everything.
I tried this :
1 | local V = "145" |
2 | if (V) = = "number" then |
3 | print ( "V is a number" ) |
4 | else |
5 | print ( "V is not a number" ) |
6 | end |
7 | end ) |
You can use type() to get the type of a value.
1 | local V = 145 |
2 |
3 | if type (V) = = "number" then |
4 | print ( "V is a number" ) |
5 | else |
6 | print ( "V is not a number" ) |
7 | end |
You can use tonumber() to check if a string can be converted to a number.
1 | local V = "145" |
2 | if tonumber (V) then |
3 | print ( "V is a number" ) |
4 | else |
5 | print ( "V is not a number" ) |
6 | end |
7 | end ) |