Trouble with destroying a particle.

unity says:

“No MonoBehaviour scripts in the file, or their names do not match the file name”
i cannot add as a component to my game object.

public class DestroyFinishedParticle : MonoBehaviour {

private ParticleSystem thisParticleSystem;

// Use this for initialization
void Start()
{
    thisParticleSystem = GetComponent<ParticleSystem>();
}

// Update is called once per frame
void Update () {
    if (thisParticleSystem.isPlaying)
        return;
    Destroy(gameObject);
}

}

Re-add the script or remove the script, create a new script and copy paste the functional code. Perhaps you tried to compile with an error and you’re not getting it now, so your script isn’t actually getting compiled. The solution is to add an error deliberately and then try to build, but the sure way to fix it is by re-adding or copy pasting the script into a newly made source file.