# removeElementData (Shared)

> Deletes a piece of data kept on an element.

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

## Syntax

```lua
bool removeElementData(element element, string key)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element. |
| `key` | `string` | The data's name. Keys over 128 characters are cut, with a warning. |

## Returns

`true` if it was deleted, `false` if there was no data under that key or a handler cancelled the change.

Fires `onElementDataChange` (on the server) or `onClientElementDataChange` (on a client) with a new value of `nil`. On the server, cancelling the event keeps the data; the removal reaches the players who were receiving that data.

## Example

```lua
addEventHandler("onPlayerSpawn", root, function()
    removeElementData(source, "wanted")
end)
```

## See also

- [setElementData (Server)](https://wiki.mymp.gg/en/setElementData-server.md): Keeps a piece of data on an element and, depending on sync, sends it to the players.
- [getElementData (Shared)](https://wiki.mymp.gg/en/getElementData.md): Reads a value stored on an element.
- [onElementDataChange (Server)](https://wiki.mymp.gg/en/onElementDataChange.md): Fired when a piece of an element's data changes or is removed. Cancelling the event puts the previous value back (or removes the key if it did not exist), and the change is not sent to the players.
