how to remove a component to an object through script in unity code example
Example 1: how to remove a component from an object in unity
Destroy(GetComponent<TheComponentYouWantToDestroy>());
Example 2: unity remove component in script
Destroy (gameObject);