SendMessage HELP

Im trying to acess a script on a gameobject that is called and tagged as “Enemy”. But Sendmessage doesnt work for some reason i’ve tried getting the script component, but it doesnt work because there will be more than one “Enemy” in the scene at the same time.

To make it clear, i have a script that is suppose to “Send Message” To a function called “ApplyDamage”.
That is attached to about 20 “Enemies” in the scene. And to be sure that the enemy i hit will “take damage”
i’ve got a “hit.transform” to support that.

I’ve had some help from Debug.Log, and it seems like the problem is the “SendMessage” Line in the code. In the console i get “Suppose to send message” but never “TookDamage”.
Please help im stuck here and dont know what to do!
appreciate it, Bye


if(hit.transform.gameObject.tag == "Enemy")
				Debug.Log("HIT THE ENEMY");
				var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
				Destroy(particleClone.gameObject, 0.3);
				//SendMessage GETTING ERROR HERE!!
				hit.transform.SendMessage("ApplyDamage", SendMessageOptions.DontRequireReceiver);
				Debug.Log("Suppose to send message");


    function ApplyDamage()
    	Health -= 50;

Replace Send Message bit with this:

                 // Your "Script2" is whatever your actual script name is
                 Debug.Log("Suppose to send message");

Or, for more robustness if you acidentally have an enemy without Enemy tag, or something without enemy script is wrongly assigned Enemy tag:

Script2 script = hit.transform.gameObject.GetComponent<Script2>();
if (script != null)

The reason why SendMessage isn’t working is because it can’t find a function ApplyDamage that has a parameter.

If you wanted to call SendMessage with the SendMessageOptions parameter, you’d have to call it like so:

SendMessage("ApplyDamage", null, SendMessageOptions.DontRequireReceiver);

However, You’re calling it like so:

SendMessage("ApplyDamage", SendMessageOptions.DontRequireReceiver);

which is identical to:

SendMessage("ApplyDamage", SendMessageOptions.DontRequireReceiver, 

If you want to pass the SendMessageOptions parameter, then you must call it with all three parameters. If you don’t care about the SendMessageOptions parameter, then you only need the function name. Keep in mind that in this case, you should use the “No options” version of calling the function.

SendMessage("ApplyDamage"); // No options

SendMessage("ApplyDamage", null, SendMessageOptions.DontRequireReceiver); // With options.

Please refer to the function’s documentation.