Destroy target creature. Its controller loses 2 life and you gain 2 life.
The targeted creature will have already left the battlefield before its controller loses 2 life and you gain 2 life. If it has any abilities that care about gaining or losing life, they won’t apply.
If the creature becomes an illegal target for Certain Death, no player gains or loses life. If it’s a legal target but isn’t destroyed, most likely due to having indestructible, its controller still loses 2 life and you gain 2 life.