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

TextBox character limit script not working?

This LocalScript under a TextBox contains the following code:

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

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

Changing the script to this fixed this issue:

local textbox = script.Parent
TextBox:GetPropertyChangedSignal("Text"):Connect(function()
    if string.len(script.Parent.Text) > 239 then
        print("Limit exceeded")
        local text = string.sub(script.Parent.Text, 1,239)
        script.Parent.Text = text
    end
end)

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