> 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.
