Error-The body of `ScriptEnemy.RespawnWaittime()' cannot be an iterator block because `void' is not an iterator interface type

using UnityEngine;
using System.Collections;

public class ScriptEnemy : MonoBehaviour {
	public int noofclicks=2;
	public float respawnwaittime=2;
	// Use this for initialization
	
	// Update is called once per frame
	void Update () {
		if(noofclicks <=0)
		{
		Vector3 position=new Vector3(Random.Range(-5.0F,5.0F),0,Random.Range(-5.0F,5.0F));
			RespawnWaittime();
		transform.position=position;
		noofclicks=2;
		}
	}
void RespawnWaittime()
	{
		renderer.enabled=false;
		yield return WaitForSeconds (respawnwaittime);
		renderer.enabled=true;
	}
}

So you are starting a coroutine from update but in c# you need to do it like this:

  • Define RespawnWaitTime as a function returning IEnumerator (yield makes it do that)

  • Start it by calling StartCoroutine

  • yield return new WaitForSeconds

      using UnityEngine;
      using System.Collections;
    
     public class ScriptEnemy : MonoBehaviour {
     public int noofclicks=2;
     public float respawnwaittime=2;
     // Use this for initialization
     
     // Update is called once per frame
     void Update () {
     	if(noofclicks <=0)
     	{
     	Vector3 position=new Vector3(Random.Range(-5.0F,5.0F),0,Random.Range(-5.0F,5.0F));
     		StartCoroutine(RespawnWaittime());
     	transform.position=position;
     	noofclicks=2;
     	}
     }
     IEnumerator RespawnWaittime()
     {
     	renderer.enabled=false;
     	yield return new WaitForSeconds (respawnwaittime);
     	renderer.enabled=true;
     }
    

    }