# How to reference the client that sent the command

**URL:** <https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333>\
**Category:** Help\
**Created:** [July 17, 2023, 8:25am UTC](https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333 "2023-07-17T08:25:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenWilder](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/benwilder/32/264_2.png) [@BenWilder](https://community.coherence.io/u/BenWilder)\
**Post date:** [July 17, 2023, 8:25am UTC](https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333/1 "2023-07-17T08:25:49Z")

</div>

Hi folks,

Wondering if you can help? In summary i am building a FPS style prototype and I am attempting to implement a system where for example, player A launches projectile, it hits player B and player B takes damages and player A awarded a point. My projectile is instantiated with a CoherenceSync component. To reference the client that launched the projectile, I followed the below advice ([https://docs.coherence.io/coherence-sdk-for-unity/networking-state-changes/commands](https://docs.coherence.io/coherence-sdk-for-unity/networking-state-changes/commands)).

_Alternatively, if you want to know which Client sent the command, you can add CoherenceSync sender as the first argument of the command, and the correct value will be automatically filled in by the SDK._

Simply put it would look like this:

**Sending the command on collision:**

`enemyCoherenceSync.SendCommand<PlayerHealth>(nameof(PlayerHealth.OnDamage), MessageTarget.AuthorityOnly);`

**Receive command:**

```auto
/// <summary>
/// Records the damage taken
/// </summary>
[Command]
public void OnDamage(CoherenceSync sender)
{
    // Handle damage
}

```

However, I’m getting the below error (which makes perfect sense really), but unsure if I have the prescribed implementation correct or if I’ve got confused?

Error:

> 09:21:28.414 (coherence) CoherenceSync: Unable to send command ‘PlayerHealth.OnDamage’ to ‘[network] PlayerObject(Clone)’: command PlayerHealth.OnDamage() was not found. Check the command’s name and parameters, or Bake again

_Note: I do have the method checked in the Coherence Sync config_

SDK 1.0  
Unity: 2022.3.4.f1

A broader questions would be, what would be the best practice, architecturally to implement that game behaviour that I mentioned?

Many thanks in advance!

---

<div class="post-metadata">

**Author:** ![ciro](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/ciro/32/82_2.png) [@ciro](https://community.coherence.io/u/ciro)\
**Post date:** [July 17, 2023, 1:25pm UTC](https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333/2 "2023-07-17T13:25:09Z")

</div>

Hey Ben, I’m asking the SDK team for clarification, I did some tests myself and I could use that technique. If it works, we definitely need to clarify the docs.  
Will let you know.

---

<div class="post-metadata">

**Author:** ![ciro](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/ciro/32/82_2.png) [@ciro](https://community.coherence.io/u/ciro)\
**Post date:** [July 18, 2023, 12:14pm UTC](https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333/3 "2023-07-18T12:14:16Z")

</div>

Hi Ben, I got an answer from the engine team. With that paragraph, you stumbled into a bit of legacy method that was removed a while ago. I am amending the docs to remove it, and adding a paragraph to explain how to do it in a different way.

This is what I have added, which should explain it somehow:

> **Identifying which Client sent a command**
> 
> While commands by default carry no information on who sent them in order to optimise traffic, you can create commands that include a Client ID as one of the parameters. Then, on the receiving end, compare that value with a list of connected Clients.
> 
> You can create your own implementation for these IDs or, more simply, use coherence’s built-in [Client Connections](https://docs.coherence.io/coherence-sdk-for-unity/client-messages) feature.

Is it clear? You should see it soon in the docs too.

---

<div class="post-metadata">

**Author:** ![BenWilder](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/benwilder/32/264_2.png) [@BenWilder](https://community.coherence.io/u/BenWilder)\
**Post date:** [July 18, 2023, 1:01pm UTC](https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333/4 "2023-07-18T13:01:54Z")

</div>

Hi Ciro, many thanks for check with the team and yes - this makes perfect sense. I’ll proceed by passing Client ID as you mention. Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex017/uploads/coherence/original/1X/b3aa79eb9519fac7aad7eba18f15a1e8ce60f6e2.png) [@system](https://community.coherence.io/u/system)\
**Post date:** [August 17, 2023, 1:02pm UTC](https://community.coherence.io/t/how-to-reference-the-client-that-sent-the-command/333/5 "2023-08-17T13:02:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
