🤔 Unity, huh, how?

🤔

BroadcastMessage: No receiver

BroadcastMessage X has no receiver!

Check your function is in the class scope

Make sure you have declared the function in the correct scope.
Message functions cannot be called if they are local functions.

Example

public class Example : MonoBehaviour
{
    void Update()
    {
        // This is a local function.
        // 🔴 Don't put your function inside of another.
        void MessageFunction()
        {
            ...
        }
    }

    // 🟢 This is the correct scope for message functions.
    void MessageFunction()
    {
        ...
    }
    
    public void Broadcast() => gameObject.BroadcastMessage(nameof(MessageFunction));
}

Where possible, use nameof

Using nameof makes it so your IDE can protect you against spelling mistakes.
If you do not have access to nameof because

Example

public class Example : MonoBehaviour
{
    // 🟠 Where possible, avoid using strings to refer to message functions.
    public void Broadcast() => gameObject.BroadcastMessage("MessageFunction");
    
    // 🟢 Use nameof, the function is in a scope this code can refer to by name.
    public void Broadcast() => gameObject.BroadcastMessage(nameof(MessageFunction));

    void MessageFunction() { ... }
    
    
}

Don't require a receiver

You can pass SendMessageOptions.DontRequireReceiver to BroadcastMessage so it won't print an error when there is no receiver present on the target.

gameObject.BroadcastMessage(nameof(MessageFunction), SendMessageOptions.DontRequireReceiver);

Avoid using BroadcastMessage entirely

BroadcastMessage is an expensive and brittle way to send messages between objects.
Consider using the GetComponents overload that takes a list (avoiding allocating a new array), getting an interface that defines your message function. Then loop over the results, calling your function.