Bake opaque texture to transparent with z to alpha shader

Hello, I created a foot with skin texture, I need to add an alpha transparency to the png.
My idea is to create a shader that adds an alpha from the object z value, I think I’m near to succeed but I’m missing something, here is what I’m doing:

That only add black gradient but it is not in the alpha chanel.
Thanks for your help.

I just find that the Transparency BSDF needs to be set to white. Now how can I bake the texture with the alpha to a new one ?