# onClientAssetLoad (Client)

> Fired once when an asset a script started loading in the background is ready, or has failed.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Client
- **Category**: Textures
- **URL**: https://wiki.mymp.gg/en/onClientAssetLoad

## Syntax

```lua
addEventHandler("onClientAssetLoad", root, function(bool loaded) ... end)
```

## Handler parameters

| Name | Type | Description |
| --- | --- | --- |
| `loaded` | `bool` | `true` if it loaded, `false` if it could not be read, decoded or compiled. |

## Source

The asset: a `txd` from `engineLoadTxd`, a `texture` from `engineCreateTexture`, or a `shader` from `engineCreateShader`.

It fires only for the first load. Changing a texture's pixels later does not fire it again.

## Example

```lua
local txd = engineLoadTxd("models/u6car.ktd")

addEventHandler("onClientAssetLoad", txd, function(loaded)
    if not loaded then
        outputDebugString("u6car.ktd could not be read")
        return
    end
    engineSetModelTxd("infernus", source)
end)
```

## See also

- [engineIsAssetLoaded (Client)](https://wiki.mymp.gg/en/engineIsAssetLoaded.md): Tells whether an asset a script made is ready to use.
- [engineLoadTxd (Client)](https://wiki.mymp.gg/en/engineLoadTxd.md): Loads a texture dictionary (.ktd) from a resource file under a name. It exists on this client only.
- [engineCreateTexture (Client)](https://wiki.mymp.gg/en/engineCreateTexture.md): Creates a texture from an image file in the resource or from image bytes in memory. The texture exists on this client only.
- [engineCreateShader (Client)](https://wiki.mymp.gg/en/engineCreateShader.md): Creates a shader from a .shader file or from its source text. The shader compiles in the background.
