getAttachedElements returns  a table. 
addEventHandler ( "onClientMarkerHit", myMarker, function ( p ) 
    if ( p == localPlayer ) then 
        local attachedElements = getAttachedElements (p) 
        for _,v in ipairs ( attachedElements ) 
            detachElements ( v, p ) 
        end 
        outputChatBox (  "   hi   " .. getPlayerName(p), 100, 100, 100, true ) 
    end 
end)