# Polling Player Health

Because we do not have event listeners for detecting damage events in relation to players, we have to poll their health values and monitor them for changes if we want to produce outputs whenever a player is damaged.\
\
The script below provides an example for how to do this.

* Store player health+shields in a variable scoped to each player.
* Compare this value to each player's current health+shields every tick.
* If the current value is lower than the stored value, output a damage event in relation to the damaged player.

<div><figure><img src="/files/nTnJI2gTc05VuidvENI5" alt=""><figcaption></figcaption></figure> <figure><img src="/files/2J81K7jhuiPFKRy81L48" alt=""><figcaption></figcaption></figure></div>

**Contributors**\
Captain Punch\
RellimJoe


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.thescriptersguild.com/knowledge/scripting/guides-and-info/patterns/polling-player-health.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
