Load scene after 5 seconds

Hi,

Once the game is over i want to wait 5 seconds before loading next screen. However everything seems to be working fine except the loading time is not working even after trying with the yield method.

Pleas help

Here is the code

using UnityEngine;
using System.Collections;

public class CountdownTimer : MonoBehaviour
{
	public float timer;
	public float timerLimit = 30.0f;

	public GUIText timerText;
	private FinishLine finishLine;

	// Use this for initialization
	void Start () 
	{
		timer = timerLimit;
		SetTimerText();
		
		finishLine = GameObject.Find ("FinishLine").GetComponent<FinishLine> ();
	}
	
	// Update is called once per frame
	void Update () 
	{
		timer -= Time.deltaTime;
		SetTimerText();

		if (timer <= 0.0f)
		{
			finishLine.winLoseText.text = "YOU LOSE!";
			timer = (0);
			Application.LoadLevel ("menu");
		}
	}


	void SetTimerText()
	{
		timerText.text = "Time Left: " + timer.ToString("f0");
	}

}

Use Debug.Log to see whats going on.

You can’t debug a script if you cant see whats going on

You could do:

	float timer;
	public float timerLimit = 30.0f;
	
	public GUIText timerText;
	private FinishLine finishLine;
	
	void Start () 
	{
		finishLine = GameObject.Find ("FinishLine").GetComponent<FinishLine> ();
		timer = timerLimit;
		InvokeRepeating("CheckTimer", 1f, 1f);
	}

	void CheckTimer ()
	{
		timer -= 1f;
		SetTimerText();
		if (timer == 0)
		{
			CancelInvoke("CheckTimer");
			finishLine.winLoseText.text = "YOU LOSE!";
			Invoke("LoadMenu", 5f);
		}
	}

	void SetTimerText()
	{
		timerText.text = "Time Left: " + timer.ToString("f0");
	}

	void LoadMenu ()
	{
		Application.LoadLevel ("menu");
	}