Please help me

I’m making a game where I need the score to increase everything I collide with the edge collider, HoW do I create score that increase?!?!

public class Ball : MonoBehaviour
{
    private int score = 0;

    private void OnCollisionEnter2D(Collision2D collision)
    {
        score++;
    }
}