Player is affected by Enemy(RigidBody2D) when hitting the ground

I’m kinda new at Unity so I need help with this.
I referenced my player using RigidBody2D , but i wanted to add a Enemy and added a code the make like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spikes : MonoBehaviour {

Bboi_keyMove pm;

public GameObject spawnLoc;

private void Start ()
{
	pm = GameObject. FindGameObjectWithTag("Player").GetComponent<Bboi_keyMove> ();
}

private void OnTriggerEnter2D ()
{
	pm.rb.position = spawnLoc.transform.position;
	pm.deaths++;
	Debug.Log ("Player has died" + pm.deaths + "times");
}

}

so i made the enemy a trigger and added RigidBody2D for gravity but then I noticed that every time the enemy landed, my player would be sent to the spawn location.
i just want to know any solution/problem with the code or any way of changing they way of referencing just the player without interfering with the enemy.
(The Bboi_keyMove is my player movement.)

You should have an if statement to check if the object your spikes collide with is the player. Currently your player death runs everytime your spike collides with anything.

An easy way to do this is to add a “Player” tag to your player gameobject.

private void OnTriggerEnter2D (Collider2D other)
 {
    if(other.CompareTag("Player")
    {
        pm.rb.position = spawnLoc.transform.position;
        pm.deaths++;
        Debug.Log ("Player has died" + pm.deaths + "times");
    }
 }

Thanks for the reply!
Adding a if statement worked!