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

# Bloxstrike

> Bloxstrike api.game: the bomb, the hostages, the gamemode, dropped items, and buys.

**Bloxstrike only.** The bomb (planted, defusing, exploded, plant in progress), the hostages on the map, the gamemode, items dropped on the ground, and what everyone buys. Every getter returns the current value the moment you call it.

## Bomb

| Call               | Returns          | What it tells you                                                                        |
| ------------------ | ---------------- | ---------------------------------------------------------------------------------------- |
| `getBomb()`        | `BombState?`     | The currently planted bomb, or `nil` if no bomb is in play.                              |
| `getBombTime()`    | `number?`        | Seconds until the bomb detonates (clamped to `0` if past). `nil` when there's no bomb.   |
| `isBombPlanted()`  | `boolean`        | `true` while a bomb is in play.                                                          |
| `isBombDefusing()` | `boolean`        | `true` while someone is actively defusing.                                               |
| `isBombDefused()`  | `boolean`        | `true` once the bomb has been defused this round.                                        |
| `isBombExploded()` | `boolean`        | `true` once the bomb has detonated this round.                                           |
| `getPlanting()`    | `PlantingState?` | Info about an in-progress plant (yours or someone else's). `nil` when nobody's planting. |

See [BombState](/reference/types#game-types) and [PlantingState](/reference/types#game-types).

### Bomb signals

| Signal              | When your callback runs                                        |
| ------------------- | -------------------------------------------------------------- |
| `onBombPlanted`     | `(bomb)`: a bomb just appeared                                 |
| `onBombDefused`     | `(bomb)`: the bomb was just defused                            |
| `onBombExploded`    | `(bomb)`: the bomb just detonated                              |
| `onBombCleared`     | `()`: the bomb is gone (round ended, cleanup, etc.)            |
| `onPlantingStarted` | `(planting)`: someone started planting                         |
| `onPlantingEnded`   | `(planting)`: someone stopped planting (cancelled or finished) |

## Hostages

| Call                          | Returns                      | What it tells you                                                                                 |
| ----------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------- |
| `getHostages()`               | `{ [string]: HostageState }` | Every hostage model currently tagged in the world. Keys are internal ids (the model's string id). |
| `getHostage(key)`             | `HostageState?`              | One entry from `getHostages()`, or `nil` if that hostage left.                                    |
| `getRescueRemaining(hostage)` | `number?`                    | Seconds left on an in-progress rescue. `nil` when nobody is rescuing it.                          |
| `getRescueProgress(hostage)`  | `number`                     | Rescue progress from `0` to `1`. `0` when nobody is rescuing.                                     |

Pass the table from `getHostages()`, `getHostage()`, or a signal callback into the rescue helpers. See [HostageState](/reference/types#game-types).

### Hostage signals

| Signal             | When your callback runs                                                |
| ------------------ | ---------------------------------------------------------------------- |
| `onHostageAdded`   | `(key, hostage)`: a hostage model was tagged and tracked               |
| `onHostageRemoved` | `(key, hostage)`: a hostage left the world                             |
| `onHostageChanged` | `(key, hostage)`: state updated (idle, carrying, rescue started, etc.) |

## Gamemode

| Call                                                       | Returns   | What it tells you                                                                |
| ---------------------------------------------------------- | --------- | -------------------------------------------------------------------------------- |
| `getGamemode()`                                            | `string?` | The current gamemode, e.g. `"Bomb Defusal"`, `"Hostage Rescue"`, `"Deathmatch"`. |
| `getServerGamemode()`                                      | `string?` | The server's matchmaking mode, e.g. `"Competitive"`.                             |
| `isBombDefusal()` / `isHostageRescue()` / `isDeathmatch()` | `boolean` | Shortcuts for checking the gamemode.                                             |
| `isCompetitive()`                                          | `boolean` | `true` on competitive servers.                                                   |

### Gamemode signals

| Signal                    | When your callback runs                                   |
| ------------------------- | --------------------------------------------------------- |
| `onGamemodeChanged`       | `(gamemode)`: the gamemode changed                        |
| `onServerGamemodeChanged` | `(serverGamemode)`: the server's matchmaking mode changed |

## Dropped items

| Call                    | Returns           | What it tells you                                                                   |
| ----------------------- | ----------------- | ----------------------------------------------------------------------------------- |
| `getDroppedItems()`     | `{ DroppedItem }` | Every weapon, grenade, and bomb lying on the ground right now. Empty in Deathmatch. |
| `getDroppedItem(model)` | `DroppedItem?`    | One dropped item by its model, or `nil`.                                            |

See [DroppedItem](/reference/types#game-types).

### Dropped item signals

| Signal                 | When your callback runs                             |
| ---------------------- | --------------------------------------------------- |
| `onDroppedItemAdded`   | `(item)`: something was dropped on the ground       |
| `onDroppedItemRemoved` | `(item)`: a dropped item was picked up or despawned |

## Grenades

| Call            | Returns       | What it tells you                         |
| --------------- | ------------- | ----------------------------------------- |
| `getGrenades()` | `{ Grenade }` | Grenades in the air or cooking right now. |

Each `Grenade`: `{ id, name, position, detonateAt, friendly }`. `position` is the predicted landing spot, `detonateAt` compares against `os.clock()`. See [Grenade](/reference/types#game-types).

### Grenade signals

| Signal             | When your callback runs                     |
| ------------------ | ------------------------------------------- |
| `onGrenadeAdded`   | `(grenade)`: a grenade was thrown           |
| `onGrenadeRemoved` | `(grenade)`: a grenade detonated or expired |

## Buys

Everything every player buys or sells back during the buy period, including you.

| Call                       | Returns        | What it tells you                                                                    |
| -------------------------- | -------------- | ------------------------------------------------------------------------------------ |
| `getPurchases()`           | `{ Purchase }` | The last 32 buys and sell-backs from every player, oldest first.                     |
| `getLastPurchase(player?)` | `Purchase?`    | The newest entry, or the newest one for that player. `nil` when there is none.       |
| `getItemIcon(name)`        | `string`       | Icon asset id for a weapon or equipment name. Empty string when the name is unknown. |
| `getItemCost(name)`        | `number`       | Buy menu cost for a weapon or equipment name. `0` when the name is unknown.          |

See [Purchase](/reference/types#game-types).

### Buy signals

| Signal       | When your callback runs                                          |
| ------------ | ---------------------------------------------------------------- |
| `onPurchase` | `(purchase)`: any player bought a weapon, grenade, armor, or kit |
| `onSell`     | `(purchase)`: any player sold an item back during the buy period |

A buy is reported once the item lands on the player and their money drops, so it fires slightly after the click. Items handed out for free at the start of a round are not reported.

All of these signals disconnect on unload.

## Examples

```luau theme={null}
api.game.onPurchase:Connect(function(purchase)
    if not purchase.friendly then
        print(purchase.playerName, "bought", purchase.name, "for", purchase.cost)
    end
end)

api.game.onBombPlanted:Connect(function(bomb)
    print("bomb planted, explodes in", bomb.duration, "seconds")
end)

api.utility.connect(game:GetService("RunService").Heartbeat, function()
    local t = api.game.getBombTime()
    if t and t < 10 then
        -- flash a "DEFUSE NOW" overlay or similar
    end
end)

api.game.onHostageChanged:Connect(function(key, hostage)
    if hostage.rescuingPlayer then
        local left = api.game.getRescueRemaining(hostage)
        print(hostage.rescuingPlayer, "rescuing", key, left, "s left")
    end
end)

api.client.onRescuingChanged:Connect(function(rescuing)
    print("local rescue channel:", rescuing)
end)
```
