Health and damage reciever

Here is my delema, I have a “working” FPS game with guns and zombies. I have made it so that the zombies can follow you but they are not dealing damage. I’m relatively new to unity 3d and no little about scripting, this is my first game. To my knowledge, to make a health variable you would just make write " Var hitpoints = 100; " if I’m wrong here please correct me. Now I can’t get the zombies to deal damage to my players health. I’ve tried to research as to how to do this but i can’t find anything on it. If anyone can help me work out a health script and a script for my Zombie to attack my player it would be very appreciated and i will definitely include your name in the credits. Please help!

I think you need to make the variable global before acessing it

static var health = 100;

then on collision you could do something like this

player.GetComponent(“playerScript”).health -= 5;

not sure though not the best coder I know it has worked for me at some point.