How to limit swimming on the Z axis ?

Hi

How do i get my movement to be limited on the Z axis when swimming?

My aim is to get the player to swim ontop of the water untill a dive button is pressed. then when they swim up to the surface they are swimming on top of the water again locked on the zaxis to keep player ontop.

I have the swimming built to allow underwater swimming but i have not yet figured out how to get the player to swim ontop of the water.

Attached is an image of my current swimming set up

Thanks!

Solved