Hi all,
I have a problem separating two if, else systems in "Player enters room, before fadein".
Here's the code:
if (GetGlobalInt(1) == 0){
object[0].Visible = false;}
else object[0].Visible = true;}
if (GetGlobalInt(2) == 0);{
object[1].Visible = true;}
else
object[1].Visible = false;}
Running this script i get the error "unexpected if" and the cursor goes on the second if.
I've tried all but I can't use the second if.
Suggestions?
Thanks.
The problem is your use of end brackets after the "else..." lines. You're trying to close a bracket which hasn't been started. Remember that the number of { and } brackets should always be the same:
if (GetGlobalInt(1) == 0) object[0].Visible = false; //no need for the brackets really, as you only run one line
else object[0].Visible = true; //no end bracket here
if (GetGlobalInt(2) == 0) object[1].Visible = true; //no need for the brackets really, as you only run one line. There was also a ";" after the if statement which shouldn't be there.
else object[1].Visible = false;//no end bracket here either
If you needed to run more than one line of code in each if/else statement, you could use brackets like so:
if (GetGlobalInt(1) == 0) {
object[0].Visible = false;
//blah blah blah, more stuff here
}
else {
object[0].Visible = true; //no end bracket here
//blah blah blah, even more stuff here
}
Thank you!