If...else statement with errors

I’m new to Unity, and I have a lot of trouble scripting. I always get compile errors. I made this script to open a door. When I saved it it had two compile errors:

Assets/DoorOpen.js(12,11): BCE0044: expecting }, found ‘else’.
Assets/DoorOpen.js(8,13): BCE0043: Unexpected token: doorOpen.

Here is the script:

var doorOpen : boolean;
var selectedUnits : Array = new Array();
function OnMouseOver (){

if(selectedUnits.length <= 0){
     
if(Input.GetMouseButtonDown(0)){
	If (doorOpen = true);
	{
     	transform.Rotate(0, 90, 0);
     	transform.position = Vector3(1218.346, 7.315172, 902.15);
	} else {
     	transform.Rotate(0, 90, 0);
     	transform.Translate = Vector3(1220.346, 7.315172, 902.15);
     }
}
}

Someone please help!

  • It’s if not If

  • You are ending statement on line 8 with semicolon. Should be:

    if(){

    }