To disable game object(tilemap) when player is inside it

I need to disable a tilemap game object when the player enter into it like a hidden area. It should disable the game object when player enter into that area and enable else.
I am new to this kind of thing so please ignore my mistakes.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HdnArea : MonoBehaviour
{

    public GameObject HiddenArea;

    private bool HdnAreaVisible;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (HdnAreaVisible)
        {

            HiddenArea.SetActive(false);
        }
        else
        {
            HiddenArea.SetActive(true);
        }
}
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.CompareTag("Player"))
        {
            HdnAreaVisible = true;
        }
        else
        {
            HdnAreaVisible = false;
        }
    }
    }

But, what is your problem? That script doesn’t work? In that case try this, I’m not sure if will helps you but anyways here you have it :slight_smile:

public class HdnArea : MonoBehaviour
 {
 
     public GameObject HiddenArea;
 
     private bool HdnAreaVisible;
 
     void Update()
     {
        HiddenArea.SetActive(HdnAreaVisible);
     }
     void OnTriggerEnter2D(Collider2D col)
     {
         if (col.CompareTag("Player"))
         {
             HdnAreaVisible = true;
         }
     }

    void OnTriggerExit2D(Collider2D col)
     {
         if (col.CompareTag("Player"))
         {
             HdnAreaVisible = false;
         }
     }
 }