Making a number-only TextBox not be able to go over a certain amount?

I have a textbox that is only compatible with numbers (code below) but how would I make it so it can only go up to 10000, and then past that you can’t type anymore. Thanks :smiley:

input:GetPropertyChangedSignal("Text"):Connect(function()
   input.Text = input.Text:gsub('%D+', '');
end)

Use math.min, as strings and numbers gets implicitly converts to each other when doing mostly anything, you don’t need tosrting.

input.Text = math.min(input.Text:gsub('%D+', ''), 10000)
input:GetPropertyChangedSignal("Text"):Connect(function()
	if tonumber(input.Text) < 100000 then
		--Its under 100000 do stuff
	end
end)
1 Like