Why is my coroutine not working?

I’m trying to set a canvas (it’s disabled when the game starts) to true after a player dies, but like 5 seconds after the player has died. I’m trying to use a coroutine and an Ienumerator but it keeps the canvas disabled. This is what I have:

	IEnumerator endSceneActive()
		end.transform.position = new Vector3(0,1, zPosofDeadPlayer + 6);
		yield return new WaitForSeconds(5);

	void PlayerisDead()


You can try to do the following:

  1. Check if the Canvas is enabled in Hierarchy panel in editor after 5 seconds.
  2. Add “Debug.Log” before and after “yield return new WaitForSeconds(5);” and check if the messages appear in Console panel.
  3. Add “Debug.Log” just prior to “StartCoroutine(endSceneActive());” and check Console message

The code you provided looks good so may be the problem is not in coroutine.