Problem Gameobject parent Tag with hit mouse

Hi! Mouse can press gameobject (tag) it gameobject attach gameobject.tag next press right with mouse to detach gameboject.tag with gameobject, only select in mouse with gameobject.tag,
My script’s error
var Player : Transform;

function Update () {
 
 if(Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(0)){
 var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 var hit : RaycastHit;
 if(Physics.Raycast(ray,hit, 8020) && hit.transform.tag == "Wall")
 {
 if(Input.GetMouseButtonDown(0)){
 Player.transform.parent = hit.gameObject.transform;
  }
    else
        Player.transform.parent = null;
 }
 }
}

Thanks

function Update () {

         if(Input.GetMouseButtonDown(1)){
         var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         var hit : RaycastHit;
         if(Physics.Raycast(ray,hit, 8020)){
        if(hit.collider.tag == "Wall" && !Player.parent)
          Player.parent == hit.transform;   
      }
     }
         if(Input.GetMouseButtonDown(0)){
         Player.parent == null;
}
    }

here’s an example, assuming player is declared as Player : Transform (I think that’s what you’re saying), hard to tell what you’re after, but this may be closer