Switch GameObjects Tags with javascript

So I’m trying to close and open multiple doors with a script and here it is basically I’m just trying to switch tags but the tags won’t switch. Please Help Thanks!

`function Update () 
{

var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5,Screen.height*0.5, 0));
 if (hit.collider.gameObject.tag == "Door")
 {
 
  if(Input.GetKeyDown("e"))
  {
   hit.collider.gameObject.GetComponent.<Animation>().Play("DoorOpen");
   
   hit.collider.gameObject.tag = "Close";
  

  }
  

 }
 
   if (hit.collider.gameObject.tag == "Close")
 {
 
  if(Input.GetKeyDown("e"))
  {
   hit.collider.gameObject.GetComponent.<Animation>().Play("DoorOpen");

  hit.collider.gameObject.tag = "Door";

  }
  

 }
}
`

Ok so I was able to fix it by making the close statement else if instead of if and I made all the animations legacy.