# getElementsWithinColShape (Shared)

> Lists the elements inside a collision shape.

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

## Syntax

```lua
table getElementsWithinColShape(element shape [, string elementType = ""])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `shape` | `element` | The collision shape. |
| `elementType` | `string` | If not empty, only elements of this type, such as `"player"` or `"vehicle"`. *(default: `""`)* |

## Returns

A list of elements, empty if there are none.

Only players, peds, vehicles and objects enter a shape. The list comes from the last check, the same one that fires `onColShapeHit`.

## Example

```lua
for _, vehicle in ipairs(getElementsWithinColShape(garage, "vehicle")) do
    destroyElement(vehicle)
end
```

## See also

- [isElementWithinColShape (Shared)](https://wiki.mymp.gg/en/isElementWithinColShape.md): Tells whether an element is inside a collision shape.
- [onColShapeHit (Server)](https://wiki.mymp.gg/en/onColShapeHit.md): Fired when a player, ped, vehicle or object enters a collision shape.
