Change camera on click with specific entity

So im trying to change camera using left click on mouse with a specific weapon but i want it only when on click. and when its not it goes back to the main camera. such as when the map is enabled and when i left click a minimap will show up. How do i code that.

at the moment this is the code i have. is there something i should add. i apologize since im really not good with codes

if (app.keyboard.wasReleased(pc.KEY_1) ){

    app.root.findByName("torch").enabled = true;

    app.root.findByName("map").enabled = false;

}

if (app.keyboard.wasReleased(pc.KEY_2) ){

    app.root.findByName("torch").enabled = false;

    app.root.findByName("map").enabled = true;

}

chatGPT code?

i actually dont have any idea. but when im using a specific weapon(map) i want to be able to view a mini map on click. is it possible in one scene?

Yes, it is… the new camera needs to be a child
https://playcanvas.github.io/#/graphics/render-cubemap

Really? How? sorry still new to this coding.

btw this is for a fps game.