Enemy and player collision isn't working

I have a simple script for enemy movement and collision among player and enemy. Enemy movement is working but collision isn’t working. as so;

{
public float speed;

private Transform target;
// Start is called before the first frame update
void Start()
{
    target = GameObject.FindGameObjectWithTag("player").GetComponent<Transform>();
}

// Update is called once per frame
void Update()
{
    transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
}

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("player"))
    {
        Debug.Log("hit");
        Destroy(gameObject);
    }
}

}

Thanks but i solved the problem. I did very stupid mistake sorry for bother.

180102-screenshot-5.png

Enemy script was in the Enemy object and box collider was in the Sprite object so they couldn’t communicate. :')