How do I target placed blocks?

I am mildly experienced with commands. I was hoping to target an actual set block. I think it'll probably be done with the /execute command, as I came up with this command:

/execute @e[type=!Player] ~ ~ ~ summon LightningBolt ~ ~ ~

I appreciate your help! Thanks!


Solution 1:

You can only target a specific block by having an entity close by or if you have the coordinates. If the area in which it may be isn't too big, you could summon an armorstand that travels across in a straight line, with execute and detect. If it should happen whenever an entity stands on a gold block you could do:

execute @e ~ ~ ~ detect ~ ~-1 ~ gold_block 0 summon LightningBolt