# getElementChildren (Shared)

> Lists an element's direct children, optionally only those of one type.

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

## Syntax

```lua
table getElementChildren(element element [, string type = ""])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The parent element. |
| `type` | `string` | Only return children of this type. Empty returns all. *(default: `""`)* |

## Returns

A table with the children, empty if there are none.

Grandchildren and anything further down are left out. To go down the whole tree, use `getElementsByType`.

## Example

```lua
for _, vehicle in ipairs(getElementChildren(resourceRoot, "vehicle")) do
    setElementFrozen(vehicle, true)
end
```

## See also

- [getElementChildrenCount (Shared)](https://wiki.mymp.gg/en/getElementChildrenCount.md): Counts an element's direct children.
- [getElementParent (Shared)](https://wiki.mymp.gg/en/getElementParent.md): Reads an element's parent in the element tree.
- [getElementsByType (Server)](https://wiki.mymp.gg/en/getElementsByType-server.md): Lists every element of a type below an element of the tree on the server.
