# setElementMatrix (Shared)

> Places and turns an element from a matrix.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Elements
- **URL**: https://wiki.mymp.gg/en/setElementMatrix

## Syntax

```lua
bool setElementMatrix(element element, table matrix)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element. |
| `matrix` | `table` | A table of 4 rows of 4 numbers, like the one `getElementMatrix` returns: right, forward, up and position. The fourth column is ignored. |

## Returns

`true` if it applied, `false` if the element has no position and rotation or the matrix gives values that are not finite.

## Example

```lua
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
    local matrix = getElementMatrix(vehicle)
    matrix[4][3] = matrix[4][3] + 2
    setElementMatrix(vehicle, matrix)
end
```

### Note

A table without 4 rows of 4 finite numbers raises an error.

## See also

- [getElementMatrix (Shared)](https://wiki.mymp.gg/en/getElementMatrix.md): Reads an element's 4x4 matrix, built from its position and rotation.
- [setElementPosition (Shared)](https://wiki.mymp.gg/en/setElementPosition.md): Moves an element to a position in the world.
- [setElementRotation (Shared)](https://wiki.mymp.gg/en/setElementRotation.md): Sets an element's 3D rotation in degrees.
