Issue with if statement not checking if a text label has X amount of text inside

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to check if text has more than X amount of text stored inside it

  2. What is the issue? My if statement that checks this is not working correctly

  3. What solutions have you tried so far? I tried debugging and the script is still broken

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

function MathHandler()
	for i,v in pairs(MathFolder:GetChildren()) do
		if v:IsA("TextButton") then
				local OldText = #InputDisplay.Text
				OldText = InputDisplay.Text .. v.Text
				if OldText >=2 and not NumButtonsFolder then
				print("user added more than one sign")

Hello so i got a strange problem that is happening where my script will not check the text imputed into a text label and instead won’t even run the if statement why is this happening?

1 Like

What is the old text variable?

OldText = InputDisplay.Text .. v.Text

Try replacing that with:

if #OldText:split() >=2 and not NumButtonsFolder then

The Spilt function clones the Number Mutiple times that’s what was happening to me in my case when i tired it

old text is a string and you are comparing it with an integer, you need to do oldtext.length or something i believe

You do know that #string is the same as #string:split()

Also why are you literally defining the variable as a number but then redefining it as a concatenated string

Update i have found the issue and it is this

if OldText >=2 and not NumButtonsFolder then

if i remove the and NumbuttonsFolder it works perfectly but the moment i put that not in it just messes up why does that happen?