if if and else if are both true

If both “if” and the “else if” below it are true does the script only execute the “if” or both?

They are evaluated in order hence the word “else” meaning “instead”. It’ll only execute the “if” part if true.

Honestly, no need to ask on forums when there are plenty of precise, well crafted explanations online such as here, here or here.

1 Like

A trick is there’s actually no such thing as an elseif. There’s just an else with a body, which may begin with an if:

// this (legal) code:
if(n>10) print("arf");
else if(n>5) print("woof");

// is actually this (also legal code):
if(n>10) print("arf");
else {
  if(n>5) print("woof");
}

Following the basic rules for an if/else on the “real” one (the second one) makes it easy to see what happens.

1 Like

Also, you’ve made several posts since this. It’s courteous to acknowledge the help you’re given. :wink: