How do I access the renderer from a child?

Hi.

Right now I have a parent GameObject with a model as the child. I have two scripts attached to the parent, one for movement and the other which accesses the renderer to switch materials in an array.

When I run the game it always comes back with script trying to access renderer but no renderer found on parent.

I’ve tried using GetComponentInChildren but I’m not sure if it should go in the Movement script or the renderer script, do my scripts need to reference the other?. I’ve also tried attaching the renderer script to the model but it still requires it for the parent.

What am I doing wrong?

You can go down on the hierarchy like this:

gameObject.Find(“Parent/child/child/etc”).renderer.enabled = false;

or

Directly access the child with:

transform.Find(“ChildNameHere”).renderer.enabled = false;