# getEventHandlers (Shared)

> Lists the functions this resource put on an element's event with `addEventHandler`.

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

## Syntax

```lua
table getEventHandlers(string eventName, element attachedTo)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `eventName` | `string` | The event's name. |
| `attachedTo` | `element` | The element the handlers were put on. Its ancestors' handlers are not included. |

## Returns

A table of the functions, in the order they are called. Empty if there are none.

Other resources' handlers on the same element do not show.

## Example

```lua
for _, handler in ipairs(getEventHandlers("onPlayerJoin", root)) do
    removeEventHandler("onPlayerJoin", root, handler)
end
```

## See also

- [addEventHandler (Shared)](https://wiki.mymp.gg/en/addEventHandler.md): Makes a function run whenever the event happens on the given element or, with propagate, on any of its descendants.
- [removeEventHandler (Shared)](https://wiki.mymp.gg/en/removeEventHandler.md): Takes a function off an element's event, where addEventHandler put it.
