Getcomponent in C#

Ok, i tried to make a basic function, when you click, you launch a missile, when this missile collides with something and if that “something” has health, it will make it lose health. But i just can’t get the component “Core” where all datas about the target, so i tried something like this:

   public float speed = 5.0f;
	public float dmg = 50.0f;
	void OnCollisionEnter(Collision collision){
		if (collision.gameObject.transform.name == "target"){
			collision.gameObject.GetComponent("Core.cs").health -=dmg;
		}
	}

But it’s not working, because it seems that it’s not taking the script… Then how am i supposed to do. Since there’s no example in C# for this function, i’m asking there. Hope you can help me, and thanks in advance!

public Core _coreScriptInstance;

public float speed = 5.0f;

public float dmg = 50.0f;

    void OnCollisionEnter(Collision collision)
{

       if (collision.gameObject.transform.name == "target")
{
        _coreScriptInstance = collision.gameObject.GetComponent<Core>();
        _coreScriptInstance.health -=dmg;

}

    }