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

TextBox character limit script not working?

Asked by 5 years ago

This LocalScript under a TextBox contains the following code:

1script.Parent.Changed:Connect(function()
2    script.Parent.Text = script.Parent.Text:sub(1,239)
3end)

This is supposed to enforce a 239 character limit on the TextBox, but it doesn't. There are no errors on both the client and the server. I don't understand why this isn't working. Any help would be greatly appreciated, thanks!

1 answer

Log in to vote
0
Answered by 5 years ago

Changing the script to this fixed this issue:

1local textbox = script.Parent
2TextBox:GetPropertyChangedSignal("Text"):Connect(function()
3    if string.len(script.Parent.Text) > 239 then
4        print("Limit exceeded")
5        local text = string.sub(script.Parent.Text, 1,239)
6        script.Parent.Text = text
7    end
8end)
Ad

Answer this question