# engineSetWorldMaterial (Client)

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

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

## Syntax

```lua
bool engineSetWorldMaterial(int|string selector, material material [, string targets = world vehicle, int priority = 0])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `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. |
| `targets` | `string` | Which models it reaches: `world`, `vehicle` and `ped`, split by spaces or commas. *(default: `world vehicle`)* |
| `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.

A material set for the model with `engineSetModelMaterial` wins over the world's.

## Example

```lua
local wet = engineCreateMaterial()
engineSetMaterialValue(wet, "roughnessFactor", 0.1)
engineSetWorldMaterial("*road*", wet, "world")
```

## See also

- [engineRestoreWorldMaterial (Client)](https://wiki.mymp.gg/en/engineRestoreWorldMaterial.md): Undoes what this resource's engineSetWorldMaterial did of every model in the world.
- [engineSetModelMaterial (Client)](https://wiki.mymp.gg/en/engineSetModelMaterial.md): Replaces the chosen materials of every instance of a model with a material.
- [engineSetWorldTexture (Client)](https://wiki.mymp.gg/en/engineSetWorldTexture.md): Swaps a texture on every model of the chosen kinds that uses it. Only the models' materials change, not the txd the texture comes from.
- [engineCreateMaterial (Client)](https://wiki.mymp.gg/en/engineCreateMaterial.md): Creates a material: a shader with parameter values, which then replaces or overlays the materials of models.
