Parts of my script won't do anything

I have a code that is supposed to act as sort of a crouching script. Here’s the code…

var LeftTexture :GameObject;
var RightTexture :GameObject;
var disable : GameObject;
var sprinting : GameObject;

function Update () {
    if (Input.GetButtonDown ("Crouch"))
        if( LeftTexture.activeSelf){
            RightTexture.SetActive (true);
            LeftTexture.SetActive (false);
        }
        else if (RightTexture.activeSelf){
            LeftTexture.SetActive (true);
            RightTexture.SetActive (false);
      
            if (sprinting.activeSelf && disable.activeSelf || Input.GetButton("Jump") && disable.activeSelf)
            {
                LeftTexture.SetActive (false);
                RightTexture.SetActive (true);
            }
        }
}

But, I’m not sure why, but that last part of the script doesn’t do anything…

            if (sprinting.activeSelf && disable.activeSelf || Input.GetButton("Jump") && disable.activeSelf)
            {
                LeftTexture.SetActive (false);
                RightTexture.SetActive (true);
            }

How do I fix this?

Put in some Debug.Logs and see what is actually being called. It’s possible the code is never entering the inner if.

I’d also try making sure the operator order of your ‘if’ statement is clear by adding parathensis around it.

For example, did you mean:

if ( (sprinting.activeSelf && disable.activeSelf ) || ( Input.GetButton(“Jump”) && disable.activeSelf ) )

or

if ( (sprinting.activeSelf && ( disable.activeSelf || Input.GetButton(“Jump”) ) && disable.activeSelf )?

C# and other languages have a set operator order but it makes code much clearer to read if you specify it manually.