change explosion color with detonator

I currently am making a special bomb in my game and I’d like the explosion to be the same color as the object being destroyed. I currently have the following code:

public GameObject tinyDetonator;

void Explode( Vector3 ePos ) {
	tinyDetonator.renderer.sharedMaterial = renderer.sharedMaterial;
	Instantiate( tinyDetonator, ePos, Quaternion.identity );


However, when I run this, I get the following error:

MissingComponentException: There is no ‘Renderer’ attached to the “Detonator-Tiny” game object, but a script is trying to access it.
You probably need to add a Renderer to the game object “Detonator-Tiny”. Or your script needs to check if the component is attached before using it.

Should I add a renderer (if so, how?) or is there some other way I can change the color of the explosion? Thanks!

Put that on the Detonator-Tiny’s gameObject, in a start function

Detonator[] detonators = GetComponents<Detonator>();
foreach( Detonator D in detonators )
    D.color =;

or in unityscript (Might be some mistakes, whatch out)

var detonators :  Detonator[] = GetComponents.<Detonator>();
for( var D in detonators )
    D.color =;