Why is not assigning new value ?

[HideInInspector]
public Vector3 blueScale;
[HideInInspector]
public Vector3 orangeScale;
[HideInInspector]
public Vector3 yellowScale;
[HideInInspector]
public Vector3 purpleScale;
[HideInInspector]
public Vector3 greenScale;
[HideInInspector]
public Vector3 redScale;

    public float blueEnergy;
    public float greeEnergy;
    public float orangeEnergy;
    public float purpleEnergy;
    public float redEnergy;
    public float yellowEnergy;
   
   
    [HideInInspector]
    public  Transform blue;
    [HideInInspector]
    public  Transform green;
    [HideInInspector]
    public  Transform orange;
    [HideInInspector]
    public  Transform purple;
    [HideInInspector]
    public  Transform red;
    [HideInInspector]
    public  Transform yellow;
   
    public   GameObject _blue;
    public  GameObject _green;
    public  GameObject _orange;
    public  GameObject _purple;
    public  GameObject _red;
    public  GameObject _yellow;
 
 
    public Transform FindChild(  GameObject parent, string name)
    {
        if (parent.name == name)
        {
            Debug.Log("Parent's Name is same as you are searching for");
            return null;
        }
 
        Transform pTransform = parent.GetComponent<Transform> ();
        foreach (Transform t in pTransform)
        {
            if (t.name == name)
            {
                return t;
            }
        }
        return null;
    }
 
 
    public void WhenYouDoSomething(GameObject item, Transform itemTransforms, Vector3 itemScale)
    {
        Debug.Log ("This is when");
        if (item == null)
            Debug.Log ("Item is null");
        else
        {
            itemTransforms = FindChild ( item, "line");
            itemScale = itemTransforms.localScale;
        }
        Debug.Log (itemTransforms);
    }
 
    public void FindItemsObjects()
    {
        _blue = GameObject.FindWithTag ("Blue");
        Debug.Log (_blue);
        WhenYouDoSomething (_blue, blue, blueScale);
        Debug.Log (blue);
 
        _green = GameObject.FindWithTag ("Green");
        WhenYouDoSomething (_green, green, greenScale);
 
        _orange = GameObject.FindWithTag ("Orange");
        WhenYouDoSomething (_orange, orange, orangeScale);
 
        _purple = GameObject.FindWithTag ("Purple");
        WhenYouDoSomething (_purple, purple, purpleScale);
 
        _red = GameObject.FindWithTag ("Red");
        WhenYouDoSomething (_red, red, redScale);
 
        _yellow = GameObject.FindWithTag ("Yellow");
        WhenYouDoSomething (_yellow, yellow, yellowScale);
    }
 
 
void Start()
    {
        blue = null;
        green = null;
        orange = null;
        purple = null;
        red = null;
        yellow = null;
        FindItemsObjects ();
    }

When I debug.

Debug.Log (blue); it gives me null, but in WhenYouDoSomething function when I debug Debug.Log (itemTransforms); it gives me the object with name line.

Why that transform is not assigned to blue ? or anyotherTransform that I declared?

Hello,

try changing the function declaration to this:

public void WhenYouDoSomething(GameObject item, out Transform itemTransforms, Vector3 itemScale)

Similarly, you will have to call the function like this:

WhenYouDoSomething (_blue, out blue, blueScale);

This way you’re passing the variable to the function by reference and not by value.