Can't get startColor from Particle System

I took code from Unity Documentation. Whatever I tried color haven’t changed. What am doing wrong?
(Unity - Scripting API: ParticleSystem.MainModule.startColor)

private ParticleSystem ps;

public float hSliderR = 0.0f;
public float hSliderG = 0.0f;
public float hSliderB = 0.0f;
public float hSliderA = 1.0f;

void Start() 
	ps = GetComponent<ParticleSystem> ();

void Update () {

	var main = ps.main;
	main.startColor = new Color (hSliderR, hSliderG, hSliderB, hSliderA);


Well you are accessing the wrong component. What you actually want to access is the particle system’s renderer. Here is an example:

        private ParticleSystem ps;
        public Color yourColor;
        void Start()
            ps = GetComponent<ParticleSystem>();

            // This auto sets the fourth slider so it shows the color at its brightest. 
            // If it is set to 0 it would show no color.
            yourColor.a = 255;
        void Update()
            ps.GetComponent<ParticleSystemRenderer>().material.color = yourColor;

For all of those out there using a Particle/Additive shader the proper usage would be this:

        ps.GetComponent<ParticleSystemRenderer>().material.SetColor("_TintColor", yourColor);
        ps.GetComponent<ParticleSystemRenderer>().trailMaterial.SetColor("_TintColor", yourColor);

Just paste that into update and you can update both the trail and the material color of your particles.

Here is a video file of me using the exact code I gave you:
The second file is how I implemented it. First I put the particle system on the object that I wanted to have particles. Then I attached my script to that object. My script then allows you to change the color of your choice. Whatever color that is it will change the particles to it during run time. So here it is:

Thanks for the answer, I checked ur example code and it seems it’s not working for me. And I can’t figure out why.

Attach this script to your particle system, and it will change the start color :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleSystemStartColorController : MonoBehaviour {
    public Color color =;

    ParticleSystem.MainModule mainModule;

	// Use this for initialization
	void Start ()
        ParticleSystem ps = GetComponent<ParticleSystem>();
        mainModule = ps.main;
	// Update is called once per frame
	void Update ()
        mainModule.startColor = color;

Remove [ExecuteInEditMode] if you don’t want it to run outside of play mode.

Note that to modify shuriken particle systems, you need to access the different modules.