Cant get object with raycasting.

I don’t understand why this isn’t working:

if (Physics.Raycast (CrosshairRay, out hit, PickUpDistance)) {
            Destroy(hit.collider.GameObject);
        }

what i want to do is get the gameobject the ray hits and destroy it i know its something to do with the “Destroy()” line, but why is this not working its giving me errors:

1: error CS1061: Type UnityEngine.Collider' does not contain a definition for GameObject’ and no extension method GameObject' of type UnityEngine.Collider’ could be found (are you missing a using directive or an assembly reference?)

2: error CS1502: The best overloaded method match for `UnityEngine.Object.Destroy(UnityEngine.Object)’ has some invalid arguments

3: error CS1503: Argument #1' cannot convert object’ expression to type `UnityEngine.Object’

I’m not sure about the questions you ask but it looks like your if statement will fail anyway as you are checking the tag of the object after you have destroyed it

I’m asking why the code isn’t working and how to fix it, i want to destroy an object the ray is hitting.

This is weird it just started working all of a sudden when i restarted unity.

It might be related to convert line endings I think