gameObject.GetComponent(); returning the collider of a different game object, what have I done wrong?

So I have a single c# script, which I’ve attached to multiple game objects. I want to get the collider attached to the game object that the script is attached to, but the problem is that when I try to do so, it returns the collider of only 1 of the objects the script is attached to, and it’s always the last one I place in the scene.

I first declare I want a collider called myCollider -

Collider myCollider;

Then in void Start () I try to assign the collider, and I assume this is where I’m going wrong, but I’ve done this so many times I don’t see how I can have got it wrong.

void Start () {

	myCollider = gameObject.GetComponent<Collider>();
	
}

I want to then disable the collider during OnMouseDown

void OnMouseDown () {
    
    myCollider.enabled = false;
    
}

Finally I try and enable the collider in void Update () using the following code.

void Update () {

	if (Input.GetMouseButton(1)){

		myCollider.enabled = true;

	}
}

The problem is no matter which game object this is attached to, when I right click, the collider that gets enabled is on one single object, not the one the script is attached to, and it’s the last one I put in the scene.

I normally wouldn’t ask a question, but I’ve searched for hours for an answer, and tried a LOT of other things. Making myCollider private doesn’t work, and I don’t know what else it can be. Please help.

don’t initialize the collider outside start

you should have
collider Mycollider;

start(){
mycollider = getcomponent<collider>();
}

but you don’t need to do this unless your enabling and disable colliders alot in which case ok yea save the collider.

you can however literally just type

Collider.enabled = false;

or true;

the thing is your inside the gameobject. You have access to the collider by defautl

you could type

gameobject.collider

or

gameobject.getcomponent();

or

this.collider

or

this.getcomponent();

but it’s unneeded

collider by itself works. your already inside the gameobject namespace so you don’t need to declare anything to put yourself there.