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

How to detect if text is a number?

so i wanna detect if the text on a TextBox is a number. how could i do that?

Edit: Nvm, i had to use tonumber

2 answers

✓ Accepted answer

do something like

if script.parent.Text = "1", "2"

2 comments

0

Unless you have higher numbers than 1-2-3-4-5-6-7-8-9-0 that may be something else

0

yeah, with infinite numbers, good idea -_-

String="124124"
if tostring(tonumber(String)) == "" then 
    print'not Number' 
else
    print'Is number'
end

That is how to detect if it HAS numbers

EDIT:

That was a joke.

here is how to make the textbox only contain numbers

textBox.Changed:connect(function(p)
	if p=="text" then
		textBox.Text = tonumber(textBox.Text)
	end
end)

3 comments

0

tysm

0

np :)

0

This is wrong...

This discussion is preserved as it was. New answers, comments, and votes are closed.