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
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
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
its not working, im trying to make it "Autocorrect" the text
Sorry i typod. On line 07 replace number = maxnumber with textbox.Text = maxnumber