How to handle numbers in my textbox

I am trying to make a system where a player can input a certain number into a textbox between 1 and 100, which will be used at the percentage of units they can send from a base.

Here is my code:

local formervalue = false

	local text = script.Parent.Text
	if typeof(text) == "Number" then
		print("its a number")
	else print("Not a number")

So far none of the outputs show that any type of texts print a number.
How do i make it so that I can input only numbers?

You can use


to convert any text to a number.

you could do

if typeof(text) == "number" then
    print("It's Number!")

or as @alexb_83 stated you could do

if tonumber(text) then
    print("It's Number!")

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