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

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

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.

2 comments

0

FireSam , Im assuming you want your amount of max character for your text box is 42? am I correct ?

0

I figured that would be it

1 answer

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

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