i am trying to make a 2d game where the level ends after you hit a flag.
right now i have this code:
using UnityEngine;

public class endflag : MonoBehaviour
{

    // Use this for initialization
    void OnCollisionEnter(Collision col)
       {
        if (col.gameObject.name == "turtle")
        {
            Application.LoadLevel("mainMenu");
        }
    }
}

from everything i have looked at this should work
(the code is on the flag and the players name is turtle)
did i write something wrong or should i have the code on the player instead

Application.LoadLevel() is obsolete you now need to use SceneManager.LoadScene(). To use the SceneManager class you need to add the UnityEngine.SceneManagement namespace to the uses clause.

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class endflag : MonoBehaviour
{

    // Use this for initialization
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.name == "turtle")
        {
	        SceneManager.LoadScene("mainMenu");
        }
    }
}