# onClientElementDestroy (Client)

> Fired when an element is about to be destroyed, while it still exists.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Client
- **Category**: Elements
- **URL**: https://wiki.mymp.gg/en/onClientElementDestroy

## Syntax

```lua
addEventHandler("onClientElementDestroy", root, function() ... end)
```

## Source

The element about to be destroyed.

When an element is destroyed, its children are destroyed before it, and each fires its own event.

## Example

```lua
local blips = {}

addEventHandler("onClientElementDestroy", root, function()
    blips[source] = nil
end)
```

## See also

- [destroyElement (Shared)](https://wiki.mymp.gg/en/destroyElement.md): Destroys an element and all of its children. Before it goes, each one fires onElementDestroy on the server or onClientElementDestroy on the client.
- [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.
- [onElementDestroy (Server)](https://wiki.mymp.gg/en/onElementDestroy.md): Fired when an element is about to be destroyed, while it still exists.
