Problem with health and level reload system

So I am making a game, and I cannot figure how to make a basic collision system. I want the player lose health when they collide with a certain GameObject, and reload the level after a certain number of hits. The health and damage should be editable, along with the GameObject. This is the way I did it-

var Enemy : GameObject;
var health = 10;
var damage = 2;

function Update(){                                             //what to do with a function inside a function?
  function OnCollisionEnter(collision:Collision) {
    if(collision.gameObject.name = Enemy){                          //refering to the var
        health -= damage;
    }
    
    if(health < 1){
      Application.LoadLevel(Application.LoadedLevel);             //I think that I have the right syntax for this....
    }
  }
}
//how would I add a hitscreen via GUI text?
//some very interesting complier errors
//thanks in advance, I'm new, and need all the help I can get

I need the answer urgently, can someone look over the code and find my mistakes?
-Thanks in advance

Issues I can see:

(1) Variable name Enemy should be changed to enemy. All variables should begin with a lower case letter, while all methods/types should begin with an upper case letter to prevent confusion or conflicts in the code.

(2) The OnCollisionEnter method should not exist within another function. I’d be very surprised if that script even compiles. Put all new functions inside the class but outside other functions. Edit: Or just outside other methods if you are in javascript.

(3) You’re comparing an object with an object name on line 7. Instead you want to check an object name against and object name. You’re also using the assignment operator (a single ‘=’), not the comparison operator (double ‘=’). Thus line 7 should read:

if(collision.gameObject.name == enemy.name)

instead of “OnCollider” use “OnControllerColliderHit”, also do “Debug.Log(“ItWorks”);” to check wheres the error. Enemy should me non-capital, infact heres a script - attach it to the enemy:

function OnTriggerEnter(x : Collider)
{
    if(x.gameObject.tag == "Player")
    {
        x.gameObject.SendMessage("GotDamaged");
    }
}

^^^ Attach to enemy, create an empty game object and attach a collide with isTrigger to true to the player, then this script onto the player:

var health : float;
var damage : float;

function GotDamaged()
{
    health -= damage;
}

correct me if im wrong