# onTrailerDetach (Server)

> Fired on the server when a trailer is unhitched from the vehicle towing it.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Server
- **Category**: Vehicles
- **URL**: https://wiki.mymp.gg/en/onTrailerDetach

## Syntax

```lua
addEventHandler("onTrailerDetach", root, function(vehicle towedBy) ... end)
```

## Handler parameters

| Name | Type | Description |
| --- | --- | --- |
| `towedBy` | `vehicle` | The vehicle that was towing the trailer. |

## Source

The trailer.

## Example

```lua
addEventHandler("onTrailerDetach", root, function(towedBy)
    local driver = getVehicleController(towedBy)
    if driver then
        outputDebugString(getPlayerName(driver) .. " soltou o reboque")
    end
end)
```

## See also

- [onTrailerAttach (Server)](https://wiki.mymp.gg/en/onTrailerAttach.md): Fired on the server when a trailer is hitched to a vehicle. Cancelling the event unhitches the trailer.
- [onClientTrailerDetach (Client)](https://wiki.mymp.gg/en/onClientTrailerDetach.md): Fired on the client when a trailer is unhitched from the vehicle towing it.
- [getVehicleTowedByVehicle (Shared)](https://wiki.mymp.gg/en/getVehicleTowedByVehicle.md): Returns the trailer or vehicle this vehicle is towing.
- [getVehicleTowingVehicle (Shared)](https://wiki.mymp.gg/en/getVehicleTowingVehicle.md): Returns the vehicle that is towing this vehicle.
