Textbox Properties help

Hi there! So I want to make sure text in a textbox actually has words or sentences, and make sure its not empty and doesn’t just have spaces.
I have tried doing:

if TextBox.Text == "" or TextBox.Text == " " then
	print("Empty")
else
	print("Not empty")
end

If you leave the text box blank or just put one space in it, it will return “Empty”, however if I put two spaces it will return “Not Empty”, is there a way to make it so it will return “Empty” if the textbox is just full of spaces?

I believe you could use string patterns for it.

There are some exisiting posts on it.

1 Like
if TextBox.Text:gsub("%s+", "")) == "" then
	print("Empty")
else
	print("Not empty")
end

This should remove the whitespace to make sure it doesn’t have any words

if text:match("%S") then
    print("not empty")

This is more efficient than gsub and should be used instead

This is not empty … it contains char(20) … a space.

Thanks to everyone for their help!