When you attack a creature with this magic weapon and roll a 20 on the d20 for the attack roll, that target takes an extra 15 Necrotic damage if it isn’t a Construct or an Undead, and you gain Temporary Hit Points equal to the amount of Necrotic damage taken.
When you roll a 20 for the attack roll vs a non-Construct/Undead: extra 15 necrotic; you gain that many Temporary Hit Points.
RollQuest ships the D&D 2024 SRD as a content pack, on a 5e character sheet that does the maths - roll from the sheet and let the numbers work themselves out. Free to start.