Undead have difficulty harming you.
If an undead targets you directly with an attack or a harmful spell, that creature must make a Wisdom saving throw against your spell save DC (an undead needn't make the save when it includes you in an area effect, such as the explosion of fireball).
On a failed save, the creature must choose a new target or forfeit targeting someone instead of you, potentially wasting the attack or spell.
On a successful save, the creature is immune to this effect for 24 hours. An undead is also immune to this effect for 24 hours if you target it with an attack or a harmful spell.