Detecting Raycast collision on an enemy to deal damage

Background:

Creating a 3rd person shooter and I have the hero shooting his pistol which creates a ray since the bullets move too fast for projectiles, ect.

I want the robot to be able to take damage when hit. This is what I have but it doesnt seem to be working. Im REALLY new to scripting so I’m kind of lost but I need to do this for a project. The main problem I’m having is that the robot is written in javascript but the player is in c# since they were assets from the asset store…

as for the code:

For the gun shooting the ray (c#):

void OnFire () {
	Vector3 dir = aimTarget.position-aimPivot.position;
	dir.Normalize();
	Ray ray = new Ray(aimPivot.position, dir);
	RaycastHit hit;
	if (Physics.Raycast(ray, out hit, 1000, mask)) {
		hit.transform.root.SendMessage("OnHit", new RayAndHit(ray, hit), SendMessageOptions.DontRequireReceiver);
	}
}

As for the robot…

function OnRayCollision(rayCollision : RayCollision)

{
if (rayCollision.ray.CompareTag(“robot”))
hitpoints=0;
}

I don’t know what OnRayCollision is, but it’s not from Unity, unlike OnTrigger… or OnCollision…

A message is send to the target. If there is a script implementing the function OnHit taking a RayAndHit in parameters attached to the same GameObject as the collider being hit, it will be called. Make sure sure there is such a function, that the spelling is right and that the parameter is correct.