How to clamp rotation of an object?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PLayermoves : MonoBehaviour
{
    public Rigidbody rg;
    public float forwarforce = 0.000001f;
    public float sidewaysforce = 0.00001f;
    public float upwardsforce = 0.000005f;
    // Update is called once per frame
    void FixedUpdate()
    {
        rg.useGravity = true;
        if (Input.GetKey("w"))
        {
            rg.AddForce(0 , 0, forwarforce * Time.deltaTime);
        }
        if (Input.GetKey("d"))
        {
            rg.AddForce(sidewaysforce * Time.deltaTime, 0, 0);
        }
        if (Input.GetKey("a"))
        {
            rg.AddForce(-sidewaysforce * Time.deltaTime, 0, 0);
        }
        if (Input.GetKey("s"))
        {
            rg.AddForce(0, 0, -forwarforce * Time.deltaTime);
        }
        if (Input.GetKey("space"))
        {
            rg.AddForce(0, upwardsforce * Time.deltaTime, 0 );
        }

      
    }
}

Actually my object that this script is attached falls down when he walks.So,please tell what can i add to stop it’s rotation.

From inspector find the Rigidbody component and there Constraints → Freeze Rotation. Check the X and Z axis to prevent is from falling and Y axis to prevent it from turning (around Y axis),