How can I check how many letters are in the textbox?

I’m trying to do a script that checks how many letters are in a TextBox and then changes Text to a number of letters.

script.Parent.Parent.TextBox.Text:GetPropertyChangedSignal("Text"):Connect(function() --If the text changed
	script.Parent.Text = "Max. ".. string.len(script.Parent.Parent.TextBox.Text).."/50" --Change "text" to numbers of letters in TextBox
end)

Unfortunately, this message pops up on the output:

Players.KotyOceloty.PlayerGui.ScreenGui.Frame.NumOfLetters.LocalScript:3: attempt to call a nil value

I’ve already tried another script from other posts but it still doesn’t work

P.S.

P.S. I’m not trying to make a character limit, but see how many of these characters are in the textbox.

I think you had mistyped by using the GetPropertyChangedSignal with the text property of TextBox. This causes an error because you tried to call a function using a string. Try using this:

script.Parent.Parent.TextBox:GetPropertyChangedSignal("Text"):Connect(function() --If the text changed
	script.Parent.Text = "Max. ".. string.len(script.Parent.Parent.TextBox.Text).."/50" --Change "text" to numbers of letters in TextBox
end)
1 Like