Bool doesn't change?

I dont know why, but when the object is as the same as “child” the bool “hasrb” doesn’t change
but when the object is the same as “parrent” “hasrb” changes. But why?

using UnityEngine;

public class moveObjects : MonoBehaviour {

public bool follow;

public bool selected = false;

public bool freeze;

public bool hasrb;

private GameObject Welder;

private welding welder;

void Start () {
    Welder = GameObject.FindGameObjectWithTag("welder");
    welder = Welder.GetComponent<welding>();
}

void Update() {
    if (gameObject == welder.child)
        if (selected == true)
    {
        follow = true;
    }
    else
    {
            follow = false;
    }

    if (gameObject == welder.parrent)
       if (selected == true)
        {
            follow = true;
        }
        else
        {
            follow = false;
        }

    if (Input.GetKeyDown(KeyCode.Mouse1))
        if (selected == true)
        freeze = !freeze;

    if (Input.GetKey(KeyCode.Q))
    {
        selected = false;
        follow = false;
        freeze = false;
    }

    if (follow == true)
        if (freeze == false)
        {
            gameObject.transform.position = Welder.transform.position;
        }

        if (gameObject == welder.child)
            if (Input.GetKey(KeyCode.Mouse1))
            freeze = false;
        else
            freeze = true;

        if (gameObject == welder.parrent)
            if (Input.GetKey(KeyCode.Mouse1))
                freeze = false;
        else
            freeze = true;
    
}
private void FixedUpdate()
{
    if (gameObject == welder.child)
    {
        hasrb = false;
    }
    else
    {
        hasrb = true;
    }

    if (gameObject == welder.parrent)
    {
        hasrb = false;
    }
    else
    {
        hasrb = true;
    }

    if (hasrb == true)
        if (gameObject.GetComponent<Rigidbody>() == false)
            gameObject.AddComponent<Rigidbody>();

    if (hasrb == false)
        if (gameObject.GetComponent<Rigidbody>() == true)
        Destroy(gameObject.GetComponent<Rigidbody>());

    if (transform.parent != null)
    {
        hasrb = false;
    }
}

private void OnTriggerEnter(Collider other)
{
    if (other.gameObject.tag == "welder")
        if (Input.GetKey(KeyCode.C))
            selected = true;

}
private void OnTriggerExit(Collider other)
{
    if (other.gameObject.tag == "welder")
        if (Input.GetKey(KeyCode.C))
            selected = false;

}

}

It has to do with the stacking of your “if” statements. Even if gameObject==welder.child and hasrb is set to false, it will be set to true again in line 90, because the second if statement does not take into account the results of the first.

Instead, do:

if(gameObject==welder.parent || gameObject==welder.child) hasrb=false;
else hasrb=true;