Mana Burn

2nd-level Transmutation
Casting Time: 1 action
Range: 30 feet
Components: VS
Duration: Instantaneous

A streak of blue energy arcs towards a target, disrupting their connection to their own reserves of magic. Make a ranged spell attack. On hit, the target takes 4d4 arcane damage and then loses up to that much mana. This spell has no effect on creatures that do not have spellcasting. A creature with Innate Spellcasting is still damaged by this spell, but loses no mana.
If you hit a creature summoned by a spell with this ability, the hit is critical and deals maximum damage, regardless of whether or not the creature has spellcasting.
At Higher Levels. When you cast this spell using a spell slot of 3rd level or higher, the damage increases by 2d4 for each slot level above 2nd.

Source: Homebrew