Gravity issue, player movement!

Ok so, I have it when i press fire 1 the gravity flips and i go up to the ceiling. The problem is the head of my player is at the ceiling. I need to flip him around so he can walk on the ceiling.
Here is the gravity script.

var speed = 10;
function Update ()
{
    if(Input.GetButtonDown("Fire1"))
    {
        if(speed > 0)
        {
            Physics.gravity = Vector3(0, speed, 0);
            speed = -10;
            
        }
        else
        {   
            Physics.gravity = Vector3(0, speed, 0);
            speed = 10;
           
        }
    }
}

When you flip directions, flip your player object 180 degrees (character controller and everything).