> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nmentities.net/llms.txt
> Use this file to discover all available pages before exploring further.

# @target

> Targets the entity that caused the trigger: the attacker, victim, killer or interacting player.

Targets the entity that **caused the trigger**. Who that is depends on the trigger the line uses:

| Trigger       | `@target` is                 |
| ------------- | ---------------------------- |
| `#onHurt`     | the damager, if any          |
| `#onAttack`   | the victim                   |
| `#onDeath`    | the killer, if any           |
| `#onInteract` | the player who right-clicked |
| `#onSpawn`    | nothing                      |

**Alias:** `@trigger`

## When to use it

`@target` is how mobs react to the specific entity that did something to them: counterattacks, thorns damage, replies to a click, rewards for the killer.

```yaml theme={null}
spiky_toast:
  model: toast
  base: zombie
  effects:
  - damage{amount=2}                       #onHurt     @target   # thorns
  - message{m=&7Sir Toast greets you!}     #onInteract @target   # reply to the clicker
  - giveitem{item=diamond;amount=1}        #onDeath    @target   # reward the killer
```

## When it resolves to nothing

`@target` can be empty, and the line then does nothing:

* On `#onSpawn`, always. A spawn has no causing entity.
* On `#onHurt` and `#onDeath` when the damage was environmental. Fall damage, fire and cactus have no attacker.

If an effect must always run, use `@self`, a radius targeter, or [`@world`](targeter-world) instead.

## Target variables

`@target` pairs with the `target.` [variable](overview) scope and placeholders. `<target.name>` in a message resolves per recipient, and `target.var.x` reads a variable stored on the targeted entity:

```yaml theme={null}
- message{m=&cYou struck &6<caster.name>&c, <target.name>!} #onHurt @target
```
