How to enable teleport area lock in Steam VR?

Hi, I am new in Unity and Steam VR. I’m trying to make an easy escape game for my project. I found that the teleport area can choose lock or unlock for player to “walk” around in VR. However, I would like to set the teleport area lock when the player haven’t open the cage door, and the area unlock when the player open the cage door.

I’m thinking of this script, but I don’t know where I can put in…

`if (cagedoorLock == false && cagedoorOpen == true)
{
locked = false;
}

if (cagedoorLock == false && cagedoorOpen == false)
{
locked = true;
}

`

using Valve.VR.InteractionSystem;

    public class ActivatingTeleporting: MonoBehaviour
    {
    // assigning your teleport area, make sure marker active is not ticked
    private TeleportArea teleport;
    
    void Start() {
    }
    
    void Update() {
            if (Input.GetKeyDown(KeyCode.A))
            {
                ActivateTeleporting();
            }
            if (Input.GetKeyDown(KeyCode.D))
            {
                DeactivateTeleporting();
            }
    }
    
    public void ActivateTeleporting() {
        teleport.locked = false;
    }
    
    public void DeactivateTeleporting() {
        teleport.locked = true;
    }
    
    }
,    using Valve.VR.InteractionSystem;
    
    public class ActivatingTeleporting: MonoBehaviour
    {
    // assigning your teleport area, make sure marker active is not ticked
    private TeleportArea teleport;
    
    void Start() {
    }
    
    void Update() {
            if (Input.GetKeyDown(KeyCode.A))
            {
                ActivateTeleporting();
            }
            if (Input.GetKeyDown(KeyCode.D))
            {
                DeactivateTeleporting();
            }
    }
    
    public void ActivateTeleporting() {
        teleport.locked = false;
    }
    
    public void DeactivateTeleporting() {
        teleport.locked = true;
    }
}