My Script that Teleports player is not Working

I’m trying to make an empty object with a Box Collider 2D object attached teleport to player to specific coordinates when the player collides with it. When the main character object called DirtGuyAlpha collides with the Box Collider 2D nothing happens. Please help me.

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

public class SceneTransition : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
       
    }


    void OnCollisionEnter(Collision collision)
    {

        if (gameObject.CompareTag("DirtGuyAlpha"))
        {
           
            GameObject player = GameObject.FindGameObjectWithTag("DirtGuyAlpha");
            player.transform.Translate(-10, -26, 0);
        }
    }
}

I’m pretty sure you’re comparing the wrong tag here. gameObject here would be the current gameobject, not the colliding one, so you’re comparing to yourself, which is either always true or never true. If this script is on the teleport point, which I believe is where you have it, it will never be DirtGuyAlpha. Instead you want to get the game object of the collision and use that (been a bit, but believe it is collision.transform.gameobject or something like that). Also note, once you have that object, you can skip the findgameobjectwithtag as you’d already have it.

First, for collision to happen at least one of the objects with collider should have a rigidbody attached.

Second, your if (gameObject.CompareTag("DirtGuyAlpha")) checks the ‘gameObject’ which is this script is attached. Should be if(collision.gameObject.CompareTag("yourTag")) .