M MY Multiplayer: Wiki
Side
Kind

getAttachedElements

Shared

Lists the elements attached directly to an element.

table getAttachedElements(element element)

Parameters

NameTypeDescription
elementelementThe target element.

Returns

A table with the elements attached to it. It is empty when nothing is attached.

Only the elements hanging directly on it are listed, not the ones hanging on those.

Example

addEventHandler("onElementDestroy", root, function()
    if getElementType(source) ~= "vehicle" then
        return
    end
    for _, attached in ipairs(getAttachedElements(source)) do
        if getElementType(attached) == "object" then
            destroyElement(attached)
        end
    end
end)

See also