Damage on Collison problem

Hi I am a senior in high school in a video game design class. My teacher really doesnt know what hes doing…my game is a Zombie game and i am trying to make it where if my zombies which have and animation of them running a rigid body a constant force a capsule collider with the ice material so they slide a smooth look at script

var target : Transform;
var damping = 1.0;
var smooth = true;

@script AddComponentMenu("Camera-Control/Smooth Look At")

function LateUpdate () {
	if (target) {
		if (smooth)
		{
			// Look at and dampen the rotation
			var rotation = Quaternion.LookRotation(target.position - transform.position);
			transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
		}
		else
		{
			// Just lookat
		    transform.LookAt(target);
		}
	}
}

function Start () {
	// Make the rigid body not change rotation
   	if (rigidbody)
		rigidbody.freezeRotation = true;
}

and a Zombie Attribute Script

using UnityEngine;
using System.Collections;

public class ZombieAttributes : MonoBehaviour {

   public float damageToInflict = 5.0f ;

}

im trying to make them cause my first person controller damage when they run into him. the script i have for my first person controller is a script i have called Health

using UnityEngine;
using System.Collections;

public class Health : MonoBehaviour {

public float maxHealth = 100.0f ;
float health = 0.0f ;
public float regeneration = 10.0f ;
 
void Start(){
   health = maxHealth ;
}
 
void Update(){
   if(health < maxHealth)
      health += regeneration * Time.deltaTime ;

   if(health > maxHealth)
      health = maxHealth ;
}
 
void OnGUI(){
   if(health < maxHealth){
      Color tempColour = GUI.color ;
      GUI.color = Color.red ;
      GUI.color = tempColour ;
   }
}
 
void OnControllerColliderHit(ControllerColliderHit other){
   if(other.gameObject.CompareTag("Zombie")){ //make sure you tag zombie as Zombie
      //if we hit a zombie, get it's script for damage->
      ZombieAttributes otherScript = other.gameObject.GetComponent<ZombieAttributes>();
      //now apply said damage
      ApplyDamage(otherScript.damageToInflict) ;
   }
}
 
void ApplyDamage(float damage){
   health -= damage ;
}
}

They either dont seem to be colliding? or one of my scripts isnt working any help would be very much appreciated.

Dude, don’t let your teachers read this question! They will get really mad - the game design teacher because of your comment, and the english teacher due to the total absence of punctuation!

Anyway, your problem is OnControllerColliderHit: this event occurs when the character hits something, not when something hits it. Since the enemies are rigidbodies, you can use OnCollisionEnter in the enemy or player scripts - OnCollision events are sent to both, the rigidbody and the hit object.

In your case, it would be easier to place the code in the enemy script:

public float damageToInflict = 5.0f ;

void OnCollisionEnter(Collision col){
  if (col.transform.CompareTag("Player")){
    Health hScript = col.transform.GetComponent<Health>();
    hScript.ApplyDamage(damageToInflict);
  }
}