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

Max character in text box script is not working! Could someone help me?

Asked by 3 years ago

I made this max characters local script for the textbox, but it won't work. The character counter works, but it doesn't prevent the text from exceeded 42 characters.

Here's the script:

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
    local txt = script.Parent.Text
    local chars = string.len(txt)
    script.Parent.Parent.MaxCharacter.Text = chars.." / 42" --Shows the current characters of the text.

    if chars < 42 then
        txt = txt:sub(1,42)
    end
end)    

If someone could help me, that would be greatly appreciated.

0
FireSam , Im assuming you want your amount of max character for your text box is 42? am I correct ? Tizzel40 243 — 3y
0
I figured that would be it Tizzel40 243 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
    local txt = script.Parent.Text
    local chars = string.len(txt)
    script.Parent.Parent.MaxCharacter.Text = chars.." / 42" --Shows the current characters of the text.

    if chars < 42 then --That's the less than sign should be ">".
        txt = txt:sub(1,42)
    end
end)    

wow i am bad

Ad

Answer this question