I'm creating something in-game which requires the last three digits of a userId to display on an epaulette, and I'm wondering how this could be achieved. So far, I've been unable to find a way to grab specific numbers from a string of numbers.
I don't mean for this to be a request, however, is it possible to grab the last three digits of a userID, and how would this be accomplished?
Many thanks,
BritishActuaI
Yes. It is possible.
local player = game.Players.LocalPlayer print("last is "..string.sub(player.UserId,#tostring(player.UserId)-2,#tostring(player.UserId)))
In this code I made to test it, it will print the last three numbers, using string.sub. A hashtag is used to determine the length of strings. Obviously, the user ID isn't a string, so you must use tostring() to convert it for this. If you need more information,
http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation#string.sub
Thanks, Explosion