> For the complete documentation index, see [llms.txt](https://pm2plugins.gitbook.io/infinitegui/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pm2plugins.gitbook.io/infinitegui/features/click-events.md).

# Click Events

<div data-full-width="true"><figure><img src="/files/aF3xC8ZVVg3dek8qwqMR" alt=""><figcaption><p>Click Events</p></figcaption></figure></div>

<div data-full-width="true"><figure><img src="/files/xQMZA1K3Ri9xtDbvBVja" alt=""><figcaption><p>Click Event Type</p></figcaption></figure></div>

Executed when player clicks the item. Multiple events can run in sequence:

```yaml
codeclick-events:
  message:
    message: "&aHello %player%!"
  command:
    command: say %player% executed this!
  money-give:
    amount: '%input%'
  money-remove:
    amount: 100
  money-set:
    amount: '%vault_eco_balance_fixed%'
  player-picker-command:
    command: ban %player% "You are banned"
  chat-fetcher:
    message: "Type a number:"
    conditionFailMessage: "Invalid input!"
    conditions:
      is-integer:
        value: '%input%'
    click-events:
      # events after chat input given
      message:
        message: "You typed %input%!"
  offline-player-picker-command:
    command: unban %player%
  save-player-info:
    save-format: deposited:%input%+%infinitegui_player_info_deposited%
  close-inventory: {}
  title:
    title: "&6Welcome"
    subtitle: "&eEnjoy"
    fadeIn: 10
    stay: 60
    fadeOut: 10
```

**Explaining Some Events:**

* `message`: Sends a chat message or title (if using `!@!` format) to the player.
* `command`: Runs a command. `%player%` replaced with clicking player’s name. By default runs as console.
* `money-give`/`money-remove`/`money-set`: Adjust player balance. Requires Vault.
* `player-picker-command`: Open a player selection GUI, once a player chosen, executes command with `%player%` as chosen player and `%executor%` as the clicking player.
* `chat-fetcher`: Prompt the player to type something in chat. Input is stored in `%input%`. Use conditions to validate input (is integer, has money, etc.). Subsequent events run if input is valid.
* `offline-player-picker-command`: Similar to player-picker but allows selecting offline players.
* `save-player-info`: Store persistent data keyed by `infinitegui_player_info_` placeholders.
* `close-inventory`: Close the GUI.

**Wait for Conditions to Pass:** If conditions fail, the event chain stops. If a `conditionFailMessage` is set at the item level, it’s shown to the player.

***

Events trigger on click. If multiple defined, they run in sequence:

* **message:**

  ```yaml
  codeclick-events:
    message:
      message: "Hello %player%!"
  ```

  Sends a chat message to player. Supports `!@!` format to send titles: `"Title !@! subtitle !@! fadeIn !@! stay !@! fadeOut"`
* **command:**

  ```yaml
  codeclick-events:
    command:
      command: give %player% diamond 1
  ```

  Runs command as console. `%player%` replaced with clicking player.
* **title:**

  ```yaml
  codeclick-events:
    title:
      command: 'title /?/ subtitle /?/ fadeIn /?/ stay /?/ fadeOut'
  ```

  Alternative method if using a different formatting. Or just `message` with `!@!` works.
* **money-give, money-remove, money-set:**

  ```yaml
  codemoney-give:
    amount: '100'
  money-remove:
    amount: '%input%'
  money-set:
    amount: '5000'
  ```

  Adjust player’s Vault balance.
* **player-picker-command:**

  ```yaml
  codeplayer-picker-command:
    command: ban %player% Banned by %executor%
  ```

  Opens a GUI to pick a player. Once chosen, runs command with `%player%` replaced by chosen player’s name and `%executor%` by original player.
* **chat-fetcher:**

  ```yaml
  codechat-fetcher:
    message: "Type amount:"
    conditionFailMessage: "Not a number!"
    conditions:
      is-integer:
        value: '%input%'
    click-events:
      message:
        message: "You typed %input%!"
  ```

  Prompts player in chat. If conditions pass, run subsequent events.
* **offline-player-picker-command:** Similar to `player-picker-command` but also lists offline players.
* **save-player-info:**

  ```yaml
  codesave-player-info:
    save-format: deposited:%input%+%infinitegui_player_info_deposited%
  ```

  Edits persistent player data stored by InfiniteGUI. Useful for tracking custom variables.
* **close-inventory:**

  ```yaml
  codeclose-inventory: {}
  ```

  Closes the current GUI.

**Note:** `%input%` placeholder is available after a `chat-fetcher` event. `%player%` always refers to the clicking player. `%executor%` is used in events like `player-picker-command` to differentiate between chosen player and the one who triggered the command.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://pm2plugins.gitbook.io/infinitegui/features/click-events.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.
