Looking for a way to make it so enemies can only die to a certain element

I'm trying to find a way to make so some enemies will only die if the last hit is with a certain element similar to yanfly’s greater undead which I thought would work but for some reason errors out. If anyone can help me I'd greatly appreciate it.
You can have elemental skills assign a state based on the element, and using a conditional branch, check to see if the right state is applied when using the killing blow.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-way-to-make-it-so-enemies-can-only-die-to-a-certain-element.78162/