Set Objects Child to Active/Inactive(Solved)

Part of my script allowed for a gameObject to be set active/inactive depending if it was selected(or not)

if(selected)
	{
		
		// Activate/Deactivate the game object/child.
		gameObject.SetActive(true);
    }

Things have changed a little now and that gameObject has a single child that I now want to make active/inactive. There seems to be so many conflicting ideas about how to do this its confusing.

Whats the simplest way to access the child object and deactivate it. (The parent object is always active)

???

Try

transform.GetChild(0).gameObject.SetActive(false);

My answer, glad that it helps you

private var childObj : Transform;
 
 function Start () {
   childObj = transform.Find("Child Name");
 }
 
 function Update () {
   if (selected){
     childObj.active = true;
   }
 }

parentGameObject.transform.GetChild(0).gameObject.SetActive(false);

I have 3 GameObjects namely red, blue and green, and each has children objects named A1, A2, A3…A100. (all 3 objects have children of the same name).

How do I disable one specific object? Say A5 of Red, and A7 of Blue.

I actually came up with a solution based on your suggestion.

private var lightRing : Projector;
    
    function Start ()
    {
        lightRing = GetComponentInChildren(Projector);
    }
    
    if(selected)
    	{
    		lightRing.enabled = true;
    	}

if (selected)
theChild.SetActive(true); // Activate
else
theChild.SetActive(false); //Deactivate