Problems with taking damage

I’m currently working on a project with a health script and a take damage script. I’ve used the script onto an enemy I made and it works perfectly. So I’m now using it on my player but I changed it a bit since the original wouldn’t work. the script problem I am having is when it comes to the take/deal damage script
it keeps giving me this error
‘Player’ does not contain a definition for ‘TakeDamage’ and no accessible extension method ‘TakeDamage’ accepting a first argument of type ‘Player’ could be found

I’ll put the code I wrote for it but I would really like it if someone could point out the problem since I am still learning

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

public class hittingplayer : MonoBehaviour
   private void OncollisionEnter2d(Collision2D collision)

          if(collision.gameObject.TryGetComponent<Player>(out Player playerComponent))


It would help to see the code you wrote for the enemy…
For what I can understand, I think it means that the method TakeDamage() is not present on the Player class.
I suspect there’s a method in the Enemy class called TakeDamage(int damageTaken).
It should look something like this:

private void TakeDamage(int damageTaken)
     health = health - damagetaken

Make sure this method is present in the Player class aswell.
There’s most likely more efficient ways of doing this instead of copying and pasting the code… But we’ll learn that with time.