When a spell is cast targeting a creature, the target is locked in at that moment (CR 601.2c). However, legality of targets is checked again when the spell tries to resolve (CR 608.2b). If a target is no longer legal at that point, the spell is countered by the rules and does not resolve.
Hexproof means the permanent cannot be the target of spells or abilities your opponents control (CR 702.11b). If an Aura enters the battlefield attached to the creature and grants it hexproof, that creature immediately becomes an illegal target for any opponent's spell or ability that was already targeting it.
When the spell with the now-illegal target tries to resolve, the game checks all targets. Since the only target is now illegal (the creature has hexproof), the spell is countered by game rules (CR 608.2b). It goes to the graveyard without any effect.
Example: Your opponent casts Lightning Bolt targeting your Grizzly Bears. In response, you play Canopy Cover (an Aura that grants hexproof) on your Grizzly Bears. When Lightning Bolt tries to resolve, Grizzly Bears now has hexproof, making it an illegal target. Lightning Bolt is countered and your Bears survive.
Note: if the Aura only granted hexproof temporarily and it wore off before resolution, or if the spell has multiple targets and at least one remains legal, the outcome would differ (CR 608.2b).
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.