Help with Rigid Body Controller Script?

Hey, I have found a script with RigidBody which works without collision glitches unlike the one on the wiki and is a lot simpler, but unfortunately the script does not allow the player to walk left or right. Could anyone help me add this feature to the script? It would be much appreciated…thank you in advance!

public int turnSpeed;
        public int moveSpeed;
        public int jumpForce;
       
        bool onGround;
       
        // Use this for initialization
        void Start () {
       
        }
       
        // Update is called once per frame
        void FixedUpdate () {
       
                float h = Input.GetAxis("Horizontal");
                float v = Input.GetAxis("Vertical");
               
                transform.Rotate( 0, h * turnSpeed * Time.deltaTime, 0 );
                Vector3 moveAmount = transform.forward * v * moveSpeed;
                rigidbody.MovePosition( transform.position + moveAmount * Time.deltaTime );
                rigidbody.velocity = moveAmount + Vector3.Scale(rigidbody.velocity, new Vector3(0,1,0));       
               
                if (onGround  Input.GetKey(KeyCode.Space))
                {
                        rigidbody.AddForce( transform.up * jumpForce, ForceMode.Impulse );     
                        onGround = false;
                }
        }
       
        void OnCollisionEnter() {
       
                onGround = true;
               
        }
       
}

The one on the wiki works perfectly well… not sure what youre talking about.

When you collide with another rigidbody the player flys away and doesnt stop moving once collding with the ground again. Do you know why this would happen? This is for the community controller.