Trying to make dash energy system...

Hello! I am struggling with creating dash energy system.

I have this script for dashing:
void Start()
{
StartCoroutine(DashRestoreCoroutine());
}

IEnumerator DashRestoreCoroutine()
{
    if (restoreDash < 3)
    {
        restoreDash = restoreDash + 1;
        yield return new WaitForSeconds(3);
    }

}

On every dash restoreDash decreases by 1 but it doesn’t increase every 3 seconds. Can someone help? :c

You are starting your coroutine once, but it exits after the first time it goes below 3:

if  restoreDash < 3 then
add one to restoreDash  immediately
then wait 3 seconds and end the coroutine.

One way would be to loop the execution so it happens forever:

while(true /* keep doing this forever, alternatively this could be 'isDashEnabled' or something*/ ) {
	if (restoreDash < 3){ //if we are not at full charge
		restoreDash  ++; //add one to the charge immediately (you may want this to come after the wait on the next line?)
		yield return new WaitForSeconds(3); //then wait 3 seconds before checking again
	}

	yield return null; //let other processes progress and then start again
}