Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 7 days 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 225 — 7d
0
I figured that would be it Tizzel40 225 — 7d

1 answer

Log in to vote
0
Answered by 7 days 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