dnd 5e – What do I do when the enemy has an AC higher than 20?

ACs don’t get that high.

In the DMG (pg. 274), there’s a big table that lists offensive and defensive stats by CR. In that table, the listed AC for a CR 30 monster is only 19.

The Tarrasque, the highest CR monster in the game, has an AC of only 25. The runners up, the Ancient Gold and Red Dragons, have ACs of 22. Hence, it’s very unlikely that you’ll run up against an AC of 30, even at high levels.

Bonuses get you there

As you level up, you’ll accumulate abilities that will give you a bonus to your attack rolls, such as higher ability scores and proficiency, as well as things like Bardic Inspiration or magic items. All of these things add flat values to your dice roll, and thus make hitting ACs over 20 feasible.

For example, 1st level fighter, with a strength of 16 (+3) and a proficiency bonus of +2, has a +5 to hit. If she rolls a 17 on the die, she adds 5 to it, making a total attack roll value of 22. That means that she only needs to roll a 17 or higher to hit an Ancient Red Dragon, so she has a 20% chance to hit without any other bonuses. Of course, dealing enough damage to be more than an annoyance is another story.