Why isn't hit.transform.name with ray working?

so the

if(hit.transform.name == "Cancel upgrade"){

part of this script isn’t working, even though everything else is. So once I touch “greatballupgrade” all these new things come up, and even though it registers me clicking the “Cancel upgrade” gameobject, it doesn’t do anything.

Any help would be appreciated, I’m stumped. Here is the script:

  private var hit : RaycastHit;
    private var ray : Ray;//ray we create when we touch the screen
    var clone1 : SpawnBall1;
    var boughttext : GameObject;
    var buysell : GameObject;
    var behindobjects : GameObject;
    var buy : GameObject;
    var cancel : GameObject;
    var goldballupgrade1 : GameObject;
    //play boughtext animation and sound when item is bought.
    var target1 : ballmade;
      function FixedUpdate () {
        if(iPhoneInput.touchCount == 1) {
            ray = Camera.main.ScreenPointToRay(iPhoneInput.touches[0].position);
            Debug.DrawLine(ray.origin,ray.direction * 10);
            if(Physics.Raycast(ray.origin, ray.direction * 10,hit)){
     Debug.Log(hit.transform.name);//Object you touched
                 			//target1 = GameObject.Find("Ball Made").GetComponent(ballmade);
                 			//clone1 = GameObject.Find("Cylinder Spawn 3").GetComponent(SpawnBall1);
                                             }
                                             if(hit.transform.name == "Menureturn"){
                                Application.LoadLevel("LoadMenu");
            }
    
                         if(hit.transform.name == "greatball Upgrade"){
                         buysell.gameObject.active = true;
                         goldballupgrade1.gameObject.active = true;
                         behindobjects.gameObject.active = false;
    if(hit.transform.name == "Cancel upgrade"){
    buysell.gameObject.active = false;
    goldballupgrade1.gameObject.active = false;
                         behindobjects.gameObject.active = true;
    }
            }
                                 if(hit.transform.name == "goodball Upgrade"){
                                 buysell.gameObject.active = true;
            }
    } 
    }

If you format your code, it is clear why you are having the issue. The “Cancel upgrade” is inside the “greatball Upgrade” ‘if’ statement:

Here is that section formatted:

 if(hit.transform.name == "greatball Upgrade"){
    buysell.gameObject.active = true;
    goldballupgrade1.gameObject.active = true;
    behindobjects.gameObject.active = false;
    if(hit.transform.name == "Cancel upgrade"){
		buysell.gameObject.active = false;
		goldballupgrade1.gameObject.active = false;
		behindobjects.gameObject.active = true;
    }
}

There is no way that hit.transform.name == “greatball Upgrade” and hit.transform.name == “Cancel upgrade” at the same time.