missing component exception even though the component is there?

I’m getting this annoying error for missing component exception
the strange thing is, it works fine and does exactly what I want
the component is there as well on the object that is getting the difficulty
this is the part of the script with problems:

Destroy (GetComponent(typeof(ConstantForce)));
					Destroy (rigidbody);

just trying to remove the rigidbody, which requires removing the constantforce as well

You can’t guarantee which component will be destroyed first, so the error probably occurs when the rigidbody is destroyed before the ConstantForce.

It’s not very clean, but you could check if the ConstantForce is destroyed before you destroy the rigidbody. You would need to check every Update.

Update() {
  if(GetComponent(typeof(ConstantForce)) == null) {

Although, if suits your needs it may be simpler just to disable the ConstantForce component rather than destroy it. I think enabling/disabling is instant.

GetComponent(typeof(ConstantForce)).enabled = false;