Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 7 years ago
Edited 7 years ago

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?

1
Have you tried using #string to get the length of the string? Monsieur_Robert 338 — 7y
1
So, you just want to lock the text box once a certain character length is exceeded? ScriptGuider 5640 — 7y

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

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)
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. Arithmeticity 167 — 7y
0
I'll try to implement*. Arithmeticity 167 — 7y
Ad

Answer this question