Spawning object on collision issues

I have a system in place when the player collides with an enemy an object gets created at the coordinates of their collision. The problem is the item gets dropped at the previous location of the collision, not the current location.

Any help would be appreciated. Here’s my code:

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

public class LeaveBehind : MonoBehaviour
{
    public GameObject player;
    public GameObject block;
 

    void OnTriggerEnter2D(Collider2D other)
    {
        Instantiate(block);
        block.transform.position = player.transform.position;
       
    }
}

For anyone having similar issues I figured out the answer:

Instantiate(block, transform.position, transform.rotation);

Your real problem in your first post is you weren’t modifying the position of the instantiated block. So you instantiate block, which makes a clone of whatever block is, but then you change the position of block (not the just created clone).

It would have worked just fine like this:

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

public class LeaveBehind : MonoBehaviour
{
    public GameObject player;
    public GameObject block;
 

    void OnTriggerEnter2D(Collider2D other)
    {
        GameObject newBlock = Instantiate(block);
        newBlock.transform.position = player.transform.position;
      
    }
}