How could i automatically change detected numbers like 001, and 002 to solely 1, and 2?

Hello! Recently i’ve gone about making a system where you can type a custom number you want from a TextBox from 1-999, and then assign that number to a card tool that the player will recieve with the number they typed in assigned to the card’s value, it does it’s job completely fine but i came into an issue: You can type any number below 100 like “001, 002, 003 etc etc” and i don’t really want that, i’d only prefer for it to show a value like “1, 2, 3 etc etc”, and any other external scripts from the game only detect the card’s values like that.

My only first thought was to do a solution like

if number == 001 then
value.Value = 1
end

For every number, but that would obviously be too time consuming and incredibly unhealthy to do at the same time.

This is probably incredibly easy to do or do a workaround but i am not thinking it through, sorry if that’s the case and if any other scripts that im using are needed, feel free to ask.

What would happen if you try tonumber(001)?

What about using math.round to only allow numbers 1-999?

To fix the “001” problem just do tonumber(value) as it removes the trailing/leading (whatever you want to call it) zeroes

1 Like

Your way and DangerRangerJJD’s both worked, i haven’t exactly learned about these yet so sorry for the small inconvenience LOL

1 Like

math.round is better I guess in case user inputs decimal values

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