# getElementsByType (Server)

> Lists every element of a type below an element of the tree on the server.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Elements
- **URL**: https://wiki.mymp.gg/en/getElementsByType-server
- **Counterpart**: Also exists on the client, with its own implementation: [getElementsByType (Client)](https://wiki.mymp.gg/en/getElementsByType-client.md)

## Syntax

```lua
table getElementsByType(string type [, element startAt = root])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `type` | `string` | The type to look for, such as `"vehicle"` or a type from `createElement`. |
| `startAt` | `element` | The element the search goes down from. *(default: `root`)* |

## Returns

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

## Example

```lua
addCommandHandler("fixall", function()
    for _, vehicle in ipairs(getElementsByType("vehicle")) do
        fixVehicle(vehicle)
    end
end)
```

## See also

- [getElementsByType (Client)](https://wiki.mymp.gg/en/getElementsByType-client.md): Lists every element of a type below an element of the tree on this client.
- [getElementChildren (Shared)](https://wiki.mymp.gg/en/getElementChildren.md): Lists an element's direct children, optionally only those of one type.
- [getPlayers (Server)](https://wiki.mymp.gg/en/getPlayers.md): Lists every player on the server.
