Make code effect children of a game object

I’m looking to set several objects to invisible but I need to do it through the parent to which the meshes are children. Is there any way I could use the renderer.enabled=false; to effect all of the children from the parent?

var meshChildren : MeshRenderer;
meshChildren = gameObject.GetComponentsInChildren.();
for (var mesh : MeshRenderer in meshChildren) {
mesh.enabled = false;


Edit: i added a fix thanks to Christian. I tested the code and it works. Hope it helps.

I can’t work out why but using the code that time Iggy spat out a load of errors out at me. However upon digging a lot deeper I found something that is very like your code, but there are some minor code differences:

function Update() {

if (Input.GetKeyDown(KeyCode.Z)) {



function DoRender(){
var children : Renderer;
children = GetComponentsInChildren.();
Debug.Log (children);
for (var i : Renderer in children) {
i.enabled = false;

However I do thank you for all your patience and help =) If you didn’t help I wouldn’t have had a clue when I was even warm to being correct!