How to execute code for player on all clients? [Mirror]

I’m new to networking and making local-host multiplayer game. Probably a stupid qustion, but how to do that?
I have this code, if damage is applied I need to apply it on all clients and update UI on all clients. How to do that?

public class Health : NetworkBehaviour
{
    public void ApplyDamage(int damage) 
    {
        //change health logic
        HealthChanged.Invoke();
    }
}

Please check out the Mirror documentation and the built in examples :slight_smile:

2 Likes

You wouldn’t normally execute that kind of code “on all clients”. Normally you’d do it either on the client with authority over the networked GameObject, or on the host. Then if anything changed, like maybe the current health value, you’d then sync that value to all other clients.