Stop spawning on bool false and enable on true?

Hello, how can i turn off this by using a bool to stop spawning and then make it spawn when the bool is true? i am getting no error’s but it is not working? here is my code. This is C#

using UnityEngine;
using System.Collections;
 
public class cointopon : MonoBehaviour
{
 
  public Transform[] spawnPoints;
  public GameObject[] enemyPrefabs;
  public float amountEnemies = 20;  // Total number of enemies to spawn.
  public float yieldTimeMin = 0;
  public float  yieldTimeMax = 5;  // Don't exceed this amount of time between spawning enemies randomly.
  public int i;
  public bool state;
  
	void Update (){
	yieldTimeMin =  PlayMakerGlobals.Instance.Variables.GetFsmFloat("coinboolmin").Value;
	yieldTimeMax = 	PlayMakerGlobals.Instance.Variables.GetFsmFloat("coinboolmax").Value;
	amountEnemies = PlayMakerGlobals.Instance.Variables.GetFsmFloat("coinboolamount").Value;
	state = PlayMakerGlobals.Instance.Variables.GetFsmBool("coinbool").Value;
	if (state == true){
	Spawnblocks();
	}	
	else if (state == false) {
    Debug.Log ("false");	
	}
	}
	
    
	  public IEnumerator Spawnblocks() {
		
      for (i=0; i<amountEnemies; i++){
			
	    var randNum = Random.Range(0, spawnPoints.Length);
        yield return new WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));  // How long to wait before another enemy is instantiated.
 
        var obj = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)]; // Randomize the different enemies to instantiate.
        var pos = spawnPoints[randNum];
 
        Instantiate(obj, pos.position, pos.rotation); 
			
}}}

From geronika2004’s updates to your code, I believe you would still need a flag to check if spawning is already occurring:

private bool alreadySpawning = false;

void Update() {
    ...
    //Check if should be spawning and is not already spawning
    if (state && !alreadySpawning) {
        //Start the spawn and set the flag
        StartCoroutine(Spawnblocks());
        alreadySpawning = true;
    } else if (!state && alreadySpawning) { //Check if should not be spawning and is already spawning
        //Stop the spawn and set the flag
        StopCoroutine("Spawnblocks");
        alreadySpawning = false;
    }
}

I think this would work off the top of my head (hopefully). Any questions/comments and I will gladly respond! =)