# getElementMatrix (Shared)

> Reads an element's 4x4 matrix, built from its position and rotation.

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

## Syntax

```lua
table|false getElementMatrix(element element [, bool legacy = true])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element to read. |
| `legacy` | `bool` | With `true`, the fourth number of the first three rows is 1. With `false`, it is 0. *(default: `true`)* |

## Returns

A table of four rows of four numbers: right, forward, up and position. `false` if the element has no position or rotation.

The fourth number of the position row is always 1.

## Example

```lua
local m = getElementMatrix(localPlayer, false)
local x = m[4][1] + m[2][1] * 3
local y = m[4][2] + m[2][2] * 3
local z = m[4][3] + m[2][3] * 3
createObject("trafficcone", x, y, z)
```

## See also

- [setElementMatrix (Shared)](https://wiki.mymp.gg/en/setElementMatrix.md): Places and turns an element from a matrix.
- [getElementPosition (Shared)](https://wiki.mymp.gg/en/getElementPosition.md): Reads an element's position in the world.
- [getElementRotation (Shared)](https://wiki.mymp.gg/en/getElementRotation.md): Reads an element's rotation in degrees.
