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

How would I make it so a TextBox input needs to be a number below 60?

function PositiveIntegerMask(text)
	return text:gsub("%D+", "")
end

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	-- Replace the text with the formatted text:
	script.Parent.Text = PositiveIntegerMask(script.Parent.Text)
end)

This is already a script that makes it so the TextBox can only have an integer input. How would I make it so the input needs to be below 60.

2 answers

✓ Accepted answer

To check if it's 60 or below, you could use the "less than or equal to" symbol.

local Number = tonumber(script.Parent.Text) --This checks if it's a number. If not, it returns nil.

if Number and Number <= 60 then
	print('Number is less than or equal to sixty!')
end
function PositiveIntegerMask(text)
    local num = tonumber(text:gsub("%D+", ""))
    return tostring(math.min(num, 60))
end

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