Minus health using SendMessage("");

What is going down?

I am trying to damage a enemy using messages like so:

gameObject.SendMessage ("ApplyDamage", 5.0);

// Every script attached to the game object 
// that has an ApplyDamage function will be called.
function ApplyDamage (damage : float) {
    print (damage);

But when the function runs it has a damage at 5 that is not what I want, I want it so that when the function gets run by send message the damage variable gets minused(-5 everytime the function is ran by SendMessage).

I hope you understand, I am a bit tired I am going get some sleep and check back later.

Have a nice day.

If you read the documentation for sendMessage, you’ll see that what it does is call the function that you want (in this case “ApplyDamage”), and passes a parameter along with it (in this case, 5). What you do within your ApplyDamage (in this case) is entirely up to you. It’s not saying “apply +5 health”, it’s saying “I want to apply a damage of magnitude 5”.

In short, just write ApplyDamage how you want it to handle the arguments you pass it.