# getElementType (Shared)

> Reads an element's type, such as `"player"`, `"vehicle"` or the type given to `createElement`.

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

## Syntax

```lua
string getElementType(element element)
```

## Parameters

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

## Returns

The type's name.

### Built-in element types

- **Tree and system:** `root`, `resource`, `console`, `file`, `db-connection`
- **World and scene:** `player`, `ped`, `vehicle`, `object`, `colshape`, `ladder`, `effect`, `light`, `cinematic`
- **Audio:** `sound`, `voice-channel`
- **Rendering and assets:** `texture`, `dx-font`, `render-target`, `screen-source`, `txd`, `dui`, `material`, `shader`, `model`, `drawable`, `col`

## Example

```lua
addEventHandler("onElementDestroy", root, function()
    if getElementType(source) == "vehicle" then
        outputDebugString("a vehicle was destroyed")
    end
end)
```

## See also

- [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.
- [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.
- [isElement (Shared)](https://wiki.mymp.gg/en/isElement.md): Tells whether a value is an element that still exists.
