# engineSetModelMaterial (Client)

> Replaces the chosen materials of every instance of a model with a material.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Materials and shaders
- **URL**: https://wiki.mymp.gg/en/engineSetModelMaterial

## Syntax

```lua
bool engineSetModelMaterial(string|element model, int|string selector, material material [, int priority = 0])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `model` | `string\|element` | The model's name or a `model` element. |
| `selector` | `int\|string` | Which material: its index from 1 or its name, as `engineGetModelMaterials` lists them. The name ignores case and takes the `*` and `?` wildcards. |
| `material` | `material` | The material drawn in their place. |
| `priority` | `int` | When several resources pick the same material, the highest priority wins; between equals, the newest. *(default: `0`)* |

## Returns

`true` when it was applied.

## Example

```lua
local chrome = engineCreateMaterial("surface")
engineSetMaterialValue(chrome, "metallicFactor", 1)
engineSetMaterialValue(chrome, "roughnessFactor", 0.05)
engineSetModelMaterial("infernus", "*chrome*", chrome)
```

### Note

A name that is not a model is an error.

## See also

- [engineRestoreModelMaterial (Client)](https://wiki.mymp.gg/en/engineRestoreModelMaterial.md): Undoes what this resource's engineSetModelMaterial did of every instance of a model.
- [engineGetModelMaterials (Client)](https://wiki.mymp.gg/en/engineGetModelMaterials.md): Lists the loaded model's materials, in the order the model keeps them.
- [engineSetWorldMaterial (Client)](https://wiki.mymp.gg/en/engineSetWorldMaterial.md): Replaces the chosen materials of every model in the world with a material.
- [engineSetElementMaterial (Client)](https://wiki.mymp.gg/en/engineSetElementMaterial.md): Replaces the chosen materials of a single vehicle, ped or object with a material.
