# Vectors (vec3)

> Working with LuaGLM vectors (vec3 and vec2) in MY Multiplayer (MYMP) for positions, rotations and velocities, vector constructors and differences from MTA.

- **Platform**: MY Multiplayer (MYMP) — Lua 5.4
- **Sections**: Documentation › Guides
- **Language**: English
- **URL**: https://docs.mymp.gg/en/docs/vectors

**MY Multiplayer** (**MYMP**) uses native vector values (`vec3` and `vec2`, powered by LuaGLM) to represent spatial coordinates, rotations and velocities in Lua scripts.

## Function return values: a single vec3

Spatial functions such as `getElementPosition`, `getElementRotation` and `getElementVelocity` return **one `vec3` value**, not three separate numbers. Read its components through `.x`, `.y` and `.z`.

## Function arguments: separate numbers or a vector

Where a function signature asks for `x, y, z`, it accepts either three numbers or a single `vec3` in their place. The same rule applies to `x, y` parameters and `vec2`.

## Creating vectors

Call the built-in constructors `vec3(x, y, z)` and `vec2(x, y)` to create vectors in any client or server script.

## Example

```lua
local pos = getElementPosition(localPlayer)
print(pos.x, pos.y, pos.z)

setElementPosition(localPlayer, vec3(pos.x, pos.y, pos.z + 2))
setElementPosition(localPlayer, pos.x, pos.y, pos.z + 2)
```

## Coming from MTA

In Multi Theft Auto (MTA), `local x, y, z = getElementPosition(element)` unpacks three numbers. In MYMP, `x` receives the whole `vec3` vector and `y` and `z` become `nil`.

Some functions do return plain numbers rather than vectors; check each function's return type in the [Scripting reference](https://docs.mymp.gg/en/llms.txt).
