Whenever a creature you control dies, you may pay {X}. If you do, you gain X life.
As the ability resolves, you choose a value for X and decide whether to pay {X}. If you do decide to pay {X}, it’s too late for any player to respond since the ability is already in the midst of resolving.