C# how to make other script apply the damage

i didn’t get any errors but it won’t apply the damage.

this is the script:

using UnityEngine;
using System.Collections;

public class ZombieScript : MonoBehaviour {
	
	public int health = 100;
	private int damage;
	private float time;
	private float hrdelay = 0.5f;
	public int healthRegen = 1;
	
	// Use this for initialization
	void Start () {
	
	}
	
	
	public void Damage (int damageParam){
		damage = damageParam;
	}
	
	// Update is called once per frame
	void Update () {
	health = health - damage;
	damage = 0;
	if (Time.time > time)
		{
		time = Time.time + hrdelay;
		health = health + healthRegen;
		}
	}
}

Your method looks pretty good. I would just apply the damage in the Damage function. This would keep you from needing to store the damage as a variable of the zombie, which makes sense.

 public void Damage (int damageParam){
        health = health - damageParam;
}

Can you show the code where you are calling the damage function from another class? Everything in here seems fine.

Look at what you wrote on line 20. CollidedZombie is the first thing called “Zombie” in your scene. That’s not going to work if there are more than 1 Zombie. It needs to be assigned to “hit.collider.gameObject”.

Name variables with lowercase and functions with uppercase. No exceptions.
collidedZombie” instead of “CollidedZombie” and “ApplyDamage” instead of “dammage”.

That will work now, assuming ZombieScript works. But you didn’t post your “dammage” function from ZombieScript so there’s no way of us knowing whether you botched that one too…