Pickup coin?

I am making a 2d sidescroller. I want to pickup coins when my player collides with it but I cant seem to get it working. My player has raycast to detect collisions with the ground and the other grounds to jump on. When I walk into the coin nothing happens. I am using C#.
Could anyone help me please? :slight_smile:

add a collider to your coin, tick “trigger”
attach a script to it and write something like this (don’t copy it, it might throw some errors cause i wrote here)

void OnTriggerEnter(Collider col)
{
   //your player should have the "player" tag
   if(col.tag.contains("player"))
     {
       //remove the coin
        Destroy(gameObject);
       //you should also have a manager class where you store your score and other useful stuff
      manager.score++;  
     }
    
}