Detecting if Player is In Range of Items?

Im trying to make a simple script that will allow the player to open treasure chests within the map(using C# and Unity3d). The chests are opened using a simple if statement:

void Update(){

    if (Input.GetKey(KeyCode.E))
    {
  
        anim.Play("Open Chest");
    } 
 
}

and I’d like to know if there’s a way to modify the if statement to include some sort of detection
to see if the player character is within range.
With the code I have now pressing E opens ALL ten chests I have placed on the terrain; is there a better way to script for range other than creating a new script for each specific chest?

So I imagine this script is on the chest, so the below will find the player’s distance that you declare in minDistance from the chest in question as well as listen for the KeyCode.E

 [SerializedField] Transform player;
 [SerializedField] float minDistance = 1.5f;
    
void Update()
{
     if (Input.GetKey(KeyCode.E) && (transform.position - chest.position).magnitude <= minDistance)
     {
   
         anim.Play("Open Chest");
     } 
  
 }