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 only certain characters allowed in a text box?

I want to make only numbers 1 - 4 be entered in the text box. I dont want letters or other numbers to be entered in it.

2 answers

✓ Accepted answer
while true do
wait()
local text = script.Parent.Text
local convert = ToNumber(text)
script.Parent.IntValue.Value = convert

if script.Parent.IntValue.Value > 0 and script.Parent.IntValue.Value < 5 then
print("number is valid")
elseif script.Parent.IntValue.Value <= 0 or script.Parent.IntValue.Value >= 5 then

end

havent tested but it should work.

1 comment

0

tonumber should be lowercased

Use string.gsub. I don't know exactly how to code it but when the text box text's changes, do a check function to see if the character x isn't inside the allowed strings. If so, do a string.gsub(textbox.Text, x, "") to replace it with nothing.

1 comment

0

Is there somewhere with an example for this?

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