Script not recognizing collision

I’m a new unity dev who is currently watching Brackeys tutorial. After finishing episode 5, I decided to add the ability to jump, It didn’t go as planned. (I’m still new to C#) I ended up just deleting the extra
code. But after doing this my collision script stopped recognizing collision. My code is exactly the same as his, (Or at least I think it is), Any ideas as to why this is happening?

   public class PlayerCollision : MonoBehaviour {
    
        public PlayerMovement movement; 
    
        void OnCollisionEnter (Collision collisionInfo)
        {
            if (collisionInfo.collider.tag == "Obstacle")
            {
                movement.enabled = false;
                Debug.Log("hit!"); // This does nothing
            }
        }
    }

after the word monobehaviour press enter once, you got one of these ( { ) in the wrong place, syntax error

I’m gonna go ahead and mark this as solved. I fixed half of the problem and the part that’s left (movement.enbled) is unrelated to this question. Thanks to everyone that helped!

It looks like your code is fine, it must be something with your GameObjects.
For collision to be triggered, both GameObjects (the Player and Obstacle) should have RigidBodies attached to them, not sure but I think both of them need a Collider too.

Also, I would put the Debug.Log outside the If statement. If it works, it means your haven’t set the correct tag name.

Take a look at Unity documentation, they’re very helpful: Unity - Scripting API: Collider.OnCollisionEnter(Collision)