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

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

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

tonumber(text)

to convert any text to a number.

you could do

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

or as @alexb_83 stated you could do

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

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