Broadcast to a script question

this is what I’m doing.

script 1{

public TargetScript target;

void Hit()
 {
  target.BroadcastMessage("ApplyDamage",damage,SendMessageOptions.DontRequireReceiver);
 }
}

Now, this works when I have ApplyDamage() under TargetScript. I have another script, also attached to the same object TargetScript is attached to. I want to receive the broadcast on the other script.

I tried target.gameObject.BroadcastMessage hoping it would get the gameObject target is attached to, then broadcast to all scripts attached to the gameObject, but this did not work.

Any suggestions as to how I would do this?

Are you sure you have the ApplyDamage function in your other script as well (no typo or something)? Just tried it here and broadcast message to a target GameObject/Script (both) is received by all attached scripts that have the function.

I figured out my issue. Managed to forget to attach the script the the prefab… so it obviously would not get called. Lack of coffee error.

It should work: target.BroadcastMessage(“ApplyDamage”, damage, …) calls the function ApplyDamage(damage) in the target script and in any other script attached to the same object or to any of its children. As @hathol said, check if the ApplyDamage exists in the other script, and if its name has no typos.