How to change settings to a rigidbody when adding it to a gamobject?

I am trying to make it so that when a particular gameobject touches a game object with this script attached to it, it will add a rigidboy to the object causing it to fall and disable the collider so it can pass through objects, and after a predesignated amount of time cause it to reappear when it originally was turn destroy it’s rigidbody and turn on it’s collider, I got it all to work perfectly except for one tiny detail, I need to freeze the rigidbody’s rotation on the z axis, how to I do this?

HERE IS MY CODE:

public float respawnDelay;
public float WaitTime;

public GameObject ground;

public Rigidbody2D rb;

public Collider2D goingThroughObjects;

private Vector3 whereToTeleport;

// Use this for initialization
void Start ()
{
    goingThroughObjects = GetComponent<Collider2D>();

    rb.isKinematic = true;
    goingThroughObjects.enabled = true;
}

void OnTriggerEnter2D(Collider2D other)
{
    if(other.tag == "HeadStomp")
    {
        StartCoroutine("TouchedBreakableObjectCo");
    }

}

public IEnumerator TouchedBreakableObjectCo()
{
    whereToTeleport = ground.transform.position;
    yield return new WaitForSeconds(WaitTime);
    ground.AddComponent<Rigidbody2D>();
    rb = GetComponent<Rigidbody2D>();
    yield return new WaitForSeconds(0.2f);
    goingThroughObjects.enabled = false;
    yield return new WaitForSeconds(respawnDelay);
    Destroy (rb);
    goingThroughObjects.enabled = true;
    ground.transform.position = whereToTeleport;

PLEASE HELP

people I wanted to come help me:

@ UnityCoach

Hello !!

You have Rigidbody.freezeRotation and Rigidbody.constraints.

As indicated by tormentoarmagedoom, you can do the following :

// ...
rb = GetComponent<Rigidbody2D>();
rb.constraints = RigidbodyConstraints2D.FreezeRotation ;
// ...

Be careful, Rigidbody2D.constraints uses bitwise operations. For example, if you want to prevent the rotation on all the axes, and the translation on the X axis, use :

rb.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation ;