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

How to stop user from typing consistently in an input box that mimics ROBLOX's???

This is what I'm trying to do:

http://i.imgur.com/K6FlzfR.png

I've tried to use character detection to detect if it is over a certain character(s) it will stop the user from typing using the sub. text method. However:

Juicy ice creams

Mavericks icecre

As you can see, these all have the same character lengths yet they're quite sized differently which means that it will stop the user from typing when they reach those character lengths but not consistently.

On the other hand, you can use TextBounds but TextBounds only works for one-lined inputs so if you have multi-lined inputs like: http://i.imgur.com/K6FlzfR.png then it will stop counting when you reach the 2nd line and so on.

I need suggestions. What should I do? Any ideas? Help?

2 comments

1

Have you tried using #string to get the length of the string?

1

So, you just want to lock the text box once a certain character length is exceeded?

1 answer

✓ Accepted answer

You can use the TextFits value inside textboxes.

textbox.Changed:Connect(function()
if not textbox.TextFits then
	textbox.Text = textbox.Text:sub(1,#textbox.Text-1)
end
end)

2 comments

0

TextFits doesn't work well for multi-lined inputs. For instance, once you surpass the first line of input and onto the 2nd line, TextFits will always be false.

0

I'll try to implement*.

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