- Documentation
- Shared functions
- getEventHandlers
Function
getEventHandlers
Returns the list of functions attached to an event directly on the given element (without handlers on parents).
Syntax
table getEventHandlers(string eventName, element attachedTo)Arguments
eventNamestring- Event name.
attachedToelement- The element.
Returns
A table of functions (empty when nothing is attached).
Example
for _, fn in ipairs(getEventHandlers("onPlayerJoin", root)) do
removeEventHandler("onPlayerJoin", root, fn)
end
See also
getEventHandlerCountReturns the total number of functions attached to an event on all elements. Useful for finding leaks (e.g. someone addingonClientRenderevery second).removeEventHandlerDetaches a function from an event. You must pass the same name, element and the same function (the same variable) as inaddEventHandler- an anonymous function written again is a different function.