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

How to check if a textbox contains a number?

I just want to know if there is a specific way of doing this.

1 answer

✓ Accepted answer

You can use string.match on the string to check if there's a digit/number. string.match returns something if a match is found. Otherwise, it returns nil.

if string.match(Textbox.Text, "%d") then -- %d matches a digit 
	-- TODO: Do something if there is a number in Textbox
end

For more info, read the wiki article for string functions and pattern matching.

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