Health script and damage script dont work.

these scripts dont work for some reason, i wrote them mostly myself using references, but appearantly i did something i shouldnt have when writing them, my players doesnt get health as far as i know, and my damage script doesnt deal 10 points of damage to my player on collision. how could i fix it so that it does work?

//player Health script.js//

public var playerCurHp;
public var playerMaxHp;
playerCurHp = 100;
playerMaxHp = 100;

function ApplyDamage (damage : int) {
    playerCurHp -= damage;
    if(playerCurHp > playerMaxHp){
        playerCurHp = playerMaxHp;

    if(playerCurHp < 0){
        playerCurHp = 0;

    if(playerCurHp < 1){
        // Die();
        Debug.Log("YOU DIED!");
    //function Die () {
    //Application.LoadLevel (Application.loadedLevel);

//**apply damage script.js**//
var damage = 10;

function OnCollisionEnter (col : Collision) {
    col.gameObject.BroadCastMessage("ApplyDamage", damage,

To what is attached apply damage script.js ? Because it’s going to call ApplyDamage on whatever is colliding with what this script is attached to. Meaning, if this is attahe to the player, ApplyDamage will be called on the bullet or whatever does the damage, and the don’t have that function. Either send the message on the same gameObject, or use GetComponent to find the health script.

By the way, you’re making sure that currHealth is between min and max, there is a function for that : Mathf.Clamp.

oh, i see, i looked at this, couldnt quite figure out how to do this method of checking. the debugger freezes and lags on my computer when i try to run it, but i did fix my problem by making it a collision check in the health script and if the collided object is tagged as harmful, i lose health by a set amount. ^^ thanks for your help.