Replace Transform through trigger script

I wanted to change the camera through script. But I want the script to change its transform from the camera1 to camera2 so that it will change the movement as well (based on the script) is there anyway I can do that? (see photo below to what I’m pointing out)

I’m not sure if I understand correctly your problem, you have a Transform variable and you want to replace CorridorCamera’s trasform with that variable, right?
You can’t replace a Transform Component, but you can replace it’s values.
This script replace all values from the CorridorCameraTransform by the OtherTransform values.
Be carefull, because if the transforms are’t child from the same parent the position of the CorridorCameraTransform can do weird things.

public Transform CorridorCameraTransform;
public Transform OtherTransform;

public void ChangeTransform(){

    CorridorCameraTransform.position = OtherTransform.position;
    CorridorCameraTransform.rotation = OtherTransform.rotation;
    CorridorCameraTransform.localScale = OtherTransform.localScale;