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

How would i make a script print the last number of a value?

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

2 comments

0

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)

0

You don't need tostring() ^

1 answer

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.