Change material of Particle System?

this script doesn’t work…

var newMat : Material;

 function Start()
 {
     gameObject.GetComponent(ParticleRenderer).Renderer.Material = newMat;
 }

var newMat : Material;

function Start()
{
    gameObject.GetComponent(ParticleSystemRenderer).material = newMat;
}

in unityscript(javascript) you should use the generic version of GetComponent.

 var newMat : Material;
 
 function Start()
 {
     gameObject.GetComponent.<ParticleSystemRenderer>().material = newMat;
 }

this worked for me but in built game you should put a list of shaders to build in settings or put the min a built scene that can never navigate to xD`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShaderBrinisFixe : MonoBehaviour
{

// Create a material from code
public void FixeSahders()
{
    // Create a material with transparent diffuse shader
   
    // assign the material to the renderer
    foreach (ParticleSystemRenderer p in gameObject.GetComponentsInChildren<ParticleSystemRenderer>())
    {
        p.material.shader= Shader.Find(p.material.shader.name);
    }
}

}
`