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

How do i make a textbox number limit? please let me know ive been trying this for a long time.

How can i make it so if i put in a number above 10 in a textbox the number auto becomes 10

like if i put in 1000 it auto is 10. but i can also put in numbers below 10 with no issue

1 answer

✓ Accepted answer
local textbox = script.Parent -- Define the textbox
local maxnumber = 10
textbox:GetPropertyChangedSignal("Text"):Connect(function() -- Detect when the text changes
	local number = tonumber(textbox.Text) -- Convert the text string into a number, if text wasnt a number then it will return nil instead
	if number then -- If the textbox was a number
		if number > maxnumber then -- If textbox is greater than maxnumber
			textbox.Text = maxnumber-- set back to maxnumber
		end
	else
		print("Textbox wasn't a number!")
	end
end)

2 comments

0

its not working, im trying to make it "Autocorrect" the text

0

Sorry i typod. On line 07 replace number = maxnumber with textbox.Text = maxnumber

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