I didn't test this but let's hope it works:
01 | script.Parent.BackGround 2. Enter.MouseButton 1 Click:connect( function () |
02 | local text = script.Parent.BackGround 2. OrderNumberHandler.Text |
03 | local number = tonumber (text) |
07 | print ( "Number " , number) |
08 | local OrdersHandler = script.Parent.BackGround 3 |
10 | if number > = 6 or not number then |
11 | script.Parent.BackGround 2. Enter.Text = "Number Not found" |
Why your script doesn't work:
01 | script.Parent.BackGround 2. Enter.MouseButton 1 Click:connect( function () |
02 | local text = script.Parent.BackGround 2. OrderNumberHandler.Text |
03 | local number = tonumber (text) |
04 | print ( "Number " , number) |
05 | local OrdersHandler = script.Parent.BackGround 3 |
06 | if number > = 6 or not number then |
07 | script.Parent.BackGround 2. Enter.Text = "Number Not found" |
If a string can't be converted into a number, then tonumber()
returns nil
.
If you put something that isn't a number into text
then an error occurs at line 6, saying that it can't compare nil
to a number value. This is easily fixed by adding an if
statement to check if number
is equal to nil
.