title says it all
You can use textbox:GetPropertyChangedSignal("Text")
of the textbox and then set the textboxes text to your limit number : textbox.text = string.sub(textBox.Text, 1, maxCharacters)
You can set the MaxVisibleGraphemes
property to your character limit number you want.
True
And if you don’t need to monitor text changes for any other purpose you can connect and disconnect the event on TextBox
Focus
and FocusLost
for performance and run the code in the function one last time after FocusLost
if you wanna be extra safe
That´s a very good addition! Use this definitely.
A better idea is to merge Modern_Developer2201’s idea to set the MaxVisibleGraphemes
and also implementing your idea for more optimization.
Oh yeah, that would be the best implementation as it achieves the result we need with no text change connection or focus connection necessary
I’d personally say either this or that post is the solution Sheriff, as the part of the code that actually limits the characters is still @Andolino13’s textbox.text = string.sub(textBox.Text, 1, maxCharacters)
The MaxVisibleGraphemes
is just the visual aspect that helps the player know when they’ve reached the limit by hiding the excess characters from them
Use MaxVisibleGraphemes
if you want a simple, clean solution and don’t need extra behavior beyond visually limiting input.
Use GetPropertyChangedSignal
if you need more control such as filtering characters, performing other logic of yours or ensuring that the actual text length cannot be changed even with script manipulation.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.