> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/game.md).

# game

<table data-full-width="false"><thead><tr><th width="320">Usage: game.{interface_or_function}</th></tr></thead><tbody><tr><td></td></tr></tbody></table>

This table exposes various internal services and global objects used by Fatality, and also provides a way to retrieve any additional services you need.

## globalVars

<mark style="color:green;">**`Field`**</mark>

Type: `CGlobalVarsBase`

This service exposes global variables used by the game, such as frame time or current server time.

***

### engine <a href="#engine" id="engine"></a>

<mark style="color:green;">**`Field`**</mark>

Type: `CEngineClient`

This service exposes the engine client, which includes commonly used engine-related functions.

***

### input <a href="#input" id="input"></a>

<mark style="color:green;">**`Field`**</mark>

Type: `CCSGOInput`

This service exposes the command input system.

***

## inputSystem

<mark style="color:green;">**`Field`**</mark>

Type: `CInputSystem`

This service exposes the control input system.

***

## gameUIFuncs

<mark style="color:green;">**`Field`**</mark>

Type: `CGameUIFuncs`

This service exposes the game's UI functions.

***

## physicsQueryInterface

<mark style="color:green;">**`Field`**</mark>

Type: `CPhysicsQueryInterface`

This service exposes the game's tracing functions.

***

## gameEntitySystem

<mark style="color:green;">**`Field`**</mark>

Type: `CGameEntitySystem`

This service exposes some of the game's entity list functions.

***

## PlaySound

<mark style="color:purple;">**`Method`**</mark>

Plays a game sound.

{% hint style="info" %}
It also accepts sounds in your `csgo/sounds` directory. Only `vsnd_c` files are supported.
{% endhint %}

**Arguments**

| Name     | Type     | Description                                                   |
| -------- | -------- | ------------------------------------------------------------- |
| `sound`  | `string` | Path to the sound, e.g. `sounds/ui/weapon_cant_buy`           |
| `volume` | `number` | Volume from 0 to 1, if passed `-1` it uses the game's volume. |

**Returns**

Nothing.

**Example**

```lua
game.PlaySound('sounds/ui/weapon_cant_buy', 0.1)
```

***

## CreateParticle

<mark style="color:purple;">**`Method`**</mark>

Creates a particle effect.

`attachment` and `owner` are optional.

**Arguments**

| Name         | Type                                                            | Description                   |
| ------------ | --------------------------------------------------------------- | ----------------------------- |
| `path`       | `string`                                                        | Particle path.                |
| `lifetime`   | `number`                                                        | Particle lifetime in seconds. |
| `attachment` | [`ParticleAttachment_t`](/api/enums/particleattachment_t.md)`?` | Optional attachment mode.     |
| `owner`      | [`C_BaseEntity`](/api/instances/entities/c_baseentity.md)`*?`   | Optional owner entity.        |

**Returns**

| Type                                                 | Description        |
| ---------------------------------------------------- | ------------------ |
| [`Particle_t`](/api/instances/game/particle_t.md)`?` | Particle instance. |

**Example**

```lua
local particle = game.CreateParticle(
    "particles/entity/spectator_utility_trail.vpcf",
    2.0
)

print("particle", particle)
print("valid", particle and particle:IsValid())

if not particle or not particle:IsValid() then
    return
end

particle:SetControl(16, Vector(255.0, 0.0, 0.0))
particle:SetControl(3, Vector(2.0, 1, 2.0))

particle:Initialize({
    Vector(0, 0, 0),
    Vector(0, 0, 0),
    Vector(50, 50, 50),
    Vector(50, 50, 50),
})
```


---

# 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, and the optional `goal` query parameter:

```
GET https://lua2.fatality.win/api/instances/game.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
