How would i make my raycast script apply damage

Hello i have a raycast script, and i also have a damage script but how would i apply damage to objects when i shoot?

#pragma strict

var endBarrel :Transform;
var sound : AudioClip;
var Damage : int = 10;
 

 

function Update(){
      var hit : RaycastHit;
      var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
      
     
     
     if(Input.GetButtonDown("Fire1")){
        // you can use PlayOneShot to specify the sound...
        audio.PlayOneShot(sound);

        audio.Play();
    }

      
       
        
         
          
            if (Input.GetMouseButtonDown(0)){
          if (Physics.Raycast (endBarrel.position, transform.forward, 100))
          
         
          
          
          {
 
          }
      }
   }


This is my damage script


 var MaxHealth : int = 100;
var CurrentHealth : int = 0;
var Other : GameObject;
function Start () {
CurrentHealth = MaxHealth;
}

function Applydamage ( Damage : float) {
 if ( CurrentHealth < 0){
 return;
 }
 CurrentHealth -= Damage;
 if ( CurrentHealth == 0){
 
 Destroy( gameObject);
 }
}


You would call your damage script from inside the if(Physics.Raycast) block. However, you need to use a different Raycast call, one that returns the object that was hit (as a RaycastHit). Please take a look at the reference:

you need to identify the object your raycasthit detected, if its the type or it is the object that will receive damage, then get the object’s component and use the method that makes damage

ie

if(hit.transform.name == "enemy")
{
 hit.gameobject.getcomponent<enemyscript>().makeDamage(weapon.damage);
}

that could help you