# setElementParent (Shared)

> Makes an element a child of another in the element tree.

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

## Syntax

```lua
bool setElementParent(element element, element parent)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element to move. |
| `parent` | `element` | The new parent. |

## Returns

`true` if it changed, `false` if the element is a system one (such as `root`), came from the server (on a client), or the new parent is the element itself or one of its descendants.

## Example

```lua
local group = createElement("race-group")
local car = createVehicle("infernus", 2495, -1687, 13.5)
setElementParent(car, group)

destroyElement(group)
```

## See also

- [getElementParent (Shared)](https://wiki.mymp.gg/en/getElementParent.md): Reads an element's parent 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.
- [createElement (Shared)](https://wiki.mymp.gg/en/createElement.md): Creates an element of a type the script makes up, with nothing in the world. It goes under the resource's dynamic element root.
