Oxygen underwater

I want to make sure that when the player going under the water the oxygen level decrease and when the player return to the surface oxygen is regenerated, if oxygen underwater ends the player die.
I saw that there is a volume causes pain but after several attempts i didn’t succeed. I hope can you help me and sorry but english is not my native language.