Changing the renderer.material.color of the children OnCollisionEnter?

First of all, hello all and thanks for reading! :slight_smile:

I’d like to have my enemy flash red for a brief duration of time, when my spells hit it and then have it go back to its original color.

So far, after numerous tries and hours of research, I’ve got some result with the method posted [here][1] but it only changed one part of my character at time, and it did not work or look good over all. Not to mention I haven’t found a way to get it back to its default look after an x period of time :frowning:

Here’s my code:

var children : Renderer[];

function Start()
{
    children = GetComponentsInChildren.<Renderer>();
}

function OnCollisionEnter (collision : Collision)
{
	if(collision.gameObject.tag == "Spell") 
	{
		
		for(var i : Renderer in children)
		{
			children.material.color = Color.red;
			yield WaitForSeconds(.5);
			print("CHANGED COLORS?");
			
		}
	}
}

Now however, I can’t even get the script running because it has been accusing the error: BCE0019 : ‘children’ is not a member of ‘UnityEngine.GameObject’.

Is there any way to make this work?

Thank you all in advance!
[1]: How to access child object colours. - Questions & Answers - Unity Discussions

for(var i : Renderer in children)
{
i.material.color = Color.red;
yield WaitForSeconds(.5);
print(“CHANGED COLORS?”);
}