How to make a scene reset when it collides with an object

I know that this question has been asked many times before but I have searched for 2 hours and nothing works. I need a script that resets the scene when the player collides with an object. Please help, I’m am so irritated. (Please use JavaScript) This is 2D

  1. Name of player: Player.

  2. Name of Object: Obstacle 1

  3. Name of Scene: Maze1

I FINALLY FOUND THE ANSWER!!! I AM SO HAPPY!!!

#pragma strict

function OnCollisionEnter2D (col : Collision2D)
    {
        if(col.gameObject.name == "Obstacle1")
        {
            Application.LoadLevel("Maze1");
        }
    }

YESSS!
Thanks so much to everyone who helped me

  1. Add your scene to the build setting.

  2. Player → Attach Rigidbody and BoxCollider or whatever collider you would like to add.

  3. Obstacle 1 → Attach a BoxCollider or whatever collider you would like to add.

  4. Add this script to Player

     void OnCollisionEnter(Collision collide)
     {    
         if(collide.gameObject.name == "Obstacle1")        
         {
             Application.LoadLevel("Maze1");
         }        
     }
    

Gena rally the error come if some of code in the class is be written out of the class means (your code may be written after closing the bracket of mono behavior).

here you are missing the class name.may this one

using UnityEngine;

using UnityEngine.SceneManagement;

private void OnCollisionEnter(Collision collide)
{

 if (collide.gameObject.name == "Obstacle1")
 {
 SceneManager.LoadScene("Maze1");
 }

}