Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I check if a textbox has no characters in it?

Asked by 9 years ago

I have a custom chatbar and I have an if statement, but I don't know exactly what code I need for it.

I've tried just about every page of the wiki and nothing.

For example:

if (chat doesnt have just '' or ' ') then
--do stuff
else
(run code)
end

2 answers

Log in to vote
0
Answered by 9 years ago

You would check the Text property of the TextBox or TextLabel, example;

local TextBox = --Define this.
if TextBox.Text == "" then 
elseif TextBox.Text ~= "" then
end

If this helps, please accept my answer, it gives us both rep!

Ad
Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
9 years ago

The text property is used to determine what text is in a TextBox or TextLabel.

Your question is asking if you can determine if there's any text in a TextBox. Here's how you'd do it:

local textBox = --define textBox here

if textBox.Text ~= "" then --this checks to see if the TextBox's text is not blank, i.e. if there's any letters in it
--run code
end

Answer this question