my SendMessage isnt working, i need help

#pragma strict
var playerDistance : int;
var player : GameObject;
var attacking : boolean;
var TakeDammage : boolean;
function Start ()
{
player = GameObject.Find(“Player”);
attacking = false;
}
function Update ()
{
playerDistance = Vector3.Distance(player.transform.position, transform.position);
if(playerDistance <=2)
{
if(!attacking)
{
Invoke(“ApplyDammage”, 3);
attacking = true;
}
}
}
function ApplyDammage()
{
player.SendMessage(“SubtractHealth”);
attacking = false;

}
function OnTriggerEnter(other : Collider){
if(other.tag == “Player”){
TakeDammage = true;
}
}
function OnTriggerExit(other : Collider){
if(other.tag == “Player”){
TakeDammage = false;
}
}
this is my script but it doesnt apply damage to the player, how do i fix it, need help asap

function SubractHealth()
{
playerHealth–;
}
this is the subtract health function

Check the spelling you have. In your second post you’re missing a t from the function name.

1 Like

okay i have another question, if i want my health to decrease faster, how should i change the subtract health function, or the first script, to make that happen?
and thank you very much for answering

Either approach works. I don’t think there is a right or wrong way.

how do i manipulate the script to do that?