I cant figure out pausing a script even with unity's API new to C#

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

public class mFlash : MonoBehaviour
{
    public ParticleSystem toggleFlash;

    // Start is called before the first frame update
    void Start()
    {
        toggleFlash.Stop();
        StartCoroutine(Example());
    }

    void Update()
    {
        IEnumerator Example()
        {
            if (Input.GetMouseButtonDown(0))
            {
                toggleFlash.Play();
                yield return new WaitForSecondsRealtime(5);
                toggleFlash.Stop();
            }
       
           
           
          
        }
       
       
           
    }

}

I’ve also tried it without the void update

Well… for starters, you have an iterator function (Example) defined inside your Update function. That alone is already an issue.

As for ‘pausing’… define what you mean by ‘pausing’. A big part of writing code is defining to the computer what it is you want to do. And well, if you can’t define it for yourself/us here on the forums… you’re going to have a hard time doing so for your computer.

I will say that setting a script’s ‘enabled’ property to false will cause Update to not fire. If not having Update fire is what you want to do, that could be a route to do it by (though not necessarily the best route… for example if you wanted it to pause only when the Time.timeScale was 0). But the whole iterator function in your Update is needed to be fixed before anything in regards to Update is dealt with.

Figured it out thank you