Invisible Frames

Well, I’ve recently been hoping to make my own custom datapack. Though I faced some issues. Basically, I would like to type ‘/trigger MakeInvisible’ in chat, and it would make the nearest item frame within a 1 block space invisible. I’ve made the files and so but it seems like whenever I try to run the code, it makes a random frame invisible. And the worst part is that I can’t run the code twice unless the previous invisible item frame is broken. Do I make myself plain?
Continue to help post