Cant enable/disable particle emission

I just want to enable/disable emission from a particle system but i get an error on the third line.

Im doing everything by the book but it still errors out.

ParticleSystem.EmissionModule em = smokeObject.emission;
em.enabled = false;
smokeObject.emission = em;

Assets\packages\AirStrike\Scripts\WeaponSystem\Damage.cs(490,13): error CS0200: Property or indexer ‘ParticleSystem.emission’ cannot be assigned to – it is read only

I think I’ve been doing it this way without issues since they depreciated particlesystem.enableEmission but i’m running into issues now.

You don’t need this line (the error is there…)
smokeObject.emission = em;

The two first lines should do the job perfectly if all you want is enable/disable emission .

When I do that once I run the code it says.

NullReferenceException: Do not create your own module instances, get them from a ParticleSystem instance

I did a quick test and there is no any Error. And it works fine…

    public ParticleSystem ps;
    public bool noEmission = false;
   
    private void Update()
    {
        ParticleSystem.EmissionModule emissionModule = ps.emission;

        if (noEmission)
        {
            emissionModule.enabled = false;
        }
        else
        {
            emissionModule.enabled = true;
        }
    }

miabcb