# getElementParent (Shared)

> Reads an element's parent in the element tree.

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

## Syntax

```lua
element|nil getElementParent(element element)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element to read. |

## Returns

The parent element, or `nil` for the root, which has none.

## Example

```lua
local parent = getElementParent(source)
if parent == resourceRoot then
    outputDebugString("element of this resource's map")
end
```

## See also

- [setElementParent (Shared)](https://wiki.mymp.gg/en/setElementParent.md): Makes an element a child of another in the element tree.
- [getElementChildren (Shared)](https://wiki.mymp.gg/en/getElementChildren.md): Lists an element's direct children, optionally only those of one type.
- [getRootElement (Shared)](https://wiki.mymp.gg/en/getRootElement.md): Returns the root element, the top of the element tree. It is the same value as the global root.
