my script says OnCollisionEnter() error bce005 and it wont work

ok so im new to unity and im making an fps, this is the script i’ve made

var health = 10;
var something : GameObject;

function Update ()
{

if (OnCollisionEnter(something)) {
var health = -1;
 }
}

i want to attach this to an enemy so when they collide with a bullet they will lose 1 health (i tried to put bullet instead of GameObject but it came up with an error)

when i try to build the game it says BCE0005: Unknown identifier: ‘OnCollisionEnter’
someone help plz

OnCollisionEnter doesnt work that way, its its own function. so instead of being within update, it would look something like this:

function OnCollisionEnter (collision : Collision) {
if(collision.gameObject == something){
health -= 1;
}
}

Then obviously make sure ‘something’ and ‘health’ are defined correctly.

Note: Take syntax with a grain of salt, I don’t normally code in java.

function OnCollisionEnter(c : Collision){
//code here
}

var health = 5;

function OnCollisionEnter(collision : Collision) { 
   if (collision.gameObject.name == "Bullet") //change Bullet to whatever you bullet is called, pay attention to caps.
   {
     health--;
   }
}