what i would like is a script that would print the last number of a value
example: if my number was 15 it would print 5 ive tried to do this and it just wont work
what i would like is a script that would print the last number of a value
example: if my number was 15 it would print 5 ive tried to do this and it just wont work
The modulus opperator. % can be used for exactly what you need. Simply do local LastDigit = Number % 10 and you'll get the last digit of the number. In the case you want to remove decimals too, use math.floor(Number % 10) instead.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
string.sub(String, initivial value, value to cut) this cut a string, but 15 is a number, do you need to use tostring() this converts anything to a string, so it would be: String.sub(tostring(15), 2, 2)
You don't need tostring() ^