How would I destroy the gameobject that a raycast hit? (SOLVED)

I was making something that would destroy a gameobject when a raycast hit it, but the object that the ray hit is not a gameobject. It is a RaycastHit. How would I destroy the RaycastHit or maybe even convert the RaycastHit into a gameobject?

Assuming your RaycastHit variable is named ‘hit’, you could do:

 Destroy(hit.collider.gameObject);

You can get access to the game object from any component, so you could also use:

 Destroy(hit.transform.gameObject);

or if your game object has a rigidbody:

 Destroy(hit.rigidbody.gameObject);