OntriggerEnter isn't working.

I am currently make a 2d game were the player has to dodge randomly spawning obstacles. I’m following Blackthornprod’s unity tutorial and I don’t know why this code to check if the player is touching the obstacle isn’t working. Does anyone know how to fix this?
Heres the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Obstacle : MonoBehaviour
    public int damage = 1;
    public float speed;
    // Start is called before the first frame update
    private void Update()
        transform.Translate(Vector2.left * speed * Time.deltaTime);

    // Update is called once per frame
    void OntriggerEnter2D(Collider2D other)
        if (other.CompareTag("Player"))
            other.GetComponent<Player>().health -= damage;

Make sure, your gameObject’s isTrigger checkbox clicked.

Try adding a rigidbody to one of the objects. It is required for a trigger function to work.