Disabling a trail renderer

Hi all,

I need to disable a trail renderer once a peg is attached to a cube. I have currently tried to do this using this line :

pegObject.GetComponent(TrailRenderer).enabled = false;

but with no luck.

Any help is appreciated.

actually this line should cause errors… you need to use either (pegObject.GetComponent(typeof(TrailRenderer)) as TrailRenderer).enabled = false; or pegObject.GetComponent().enabled = false;
JS or CS you’re using?

It is c# that I am using!