# createColRectangle (Shared)

> Creates a rectangular collision shape, aligned with the world's axes and with no height limit.

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

## Syntax

```lua
element|false createColRectangle(float x, y, float width, depth)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `x, y` | `float` | The rectangle's corner with the lowest `x` and `y`. A `vec2` also works. |
| `width, depth` | `float` | The size along `x` and `y`, in metres. Negative values count as 0. A `vec2` also works. |

## Returns

The created `colshape` element, or `false` if it could not be created.

A collision shape detects players, peds, vehicles and objects by their position and fires `onColShapeHit` and `onColShapeLeave` (`onClientColShapeHit` and `onClientColShapeLeave` on a client). It goes away when the resource that created it stops.

## Example

```lua
local parking = createColRectangle(1520.0, -1700.0, 40, 25)
```

## See also

- [createColCuboid (Shared)](https://wiki.mymp.gg/en/createColCuboid.md): Creates a box-shaped collision shape, aligned with the world's axes.
- [createColPolygon (Shared)](https://wiki.mymp.gg/en/createColPolygon.md): Creates a collision shape shaped like a flat polygon, with no height limit until setColPolygonHeight gives it one.
- [onColShapeHit (Server)](https://wiki.mymp.gg/en/onColShapeHit.md): Fired when a player, ped, vehicle or object enters a collision shape.
