If I use klefki's ability to discard everything attached to it and attach it to my active and my opponent plays a hex maniac and attacks me with a mega pokemon does the attack still go through?
According to PokePop's ruling, it would not be removed or affected by Hex Maniac. The only thing the Wonder Lock Ability does is turn Klefki into a Pokemon Tool card. By this point, it's considered an Item rather than a Pokemon, kind of like how Robo Substitute is a Pokemon rather than an Item while it's in play. Hex Maniac doesn't affect Pokemon Tools, so nothing happens to Klefki at this point. It stays attached until the end of your opponent's turn, or if it is targeted by an effect that removed Pokemon Tools, such as Startling Megaphone or Xerosic.