Camera Movement Flashing

Hi, I’m trying to create a script that allows for the camera to move, on a button push, to a certain position, dictated by an empty Gameobject. The camera should be able to move in the x,y, and z directions. The only problem is, I want to be able to apply this script to multiple Groups that I imported from Google Sketchup. For example, when the button for group “A” is pushed, the camera moves to x position. On a second press of the button, the camera moves back to the starting position. But when I press the button for group “B”, the camera flashes for a second where it should be, then moves back to the original position without a second button press. Here’s the script for one group:

#pragma strict
private var outside1 : Transform;
private var originalspotTC : Transform;
private var moved = false;
static var main : Camera; 
private var CameraBlack : Transform;
private var CameraStart : Transform; 
private var BlackPicture : GameObject;
private var stringToEdit : String = "Some stuff";
function Start () {
	originalspotTC = transform.Find("/originalTC");
	outside1 = transform.Find("/Spot1");
	CameraBlack = transform.Find("/CameraBlack");
	CameraStart = transform.Find("/MainCameraStart");
	BlackPicture = GameObject.Find("/BlackTexture");
}
function OnGUI () {
	GUILayout.BeginHorizontal();
	GUILayout.Space(200);
	
	if(GUI.Button(Rect(50 , 50  , 150 , 50) , "Examine TC")){
		if(moved){		
			moved = false;
			BlackPicture.renderer.enabled = false;
}
		else
		{
			moved = true;
		}
	}
	GUILayout.EndHorizontal();

	if(moved){
		// moved is true 
		transform.position = outside1.position;
		stringToEdit = GUI.TextArea (Rect (800, 100, 100, 100), stringToEdit, 200);
		Camera.main.transform.position = CameraBlack.position;
		BlackPicture.renderer.enabled = true;

The only issue I am having is with the camera position. Any help?

is this attached to a camera? I think it is. in which case this

transform.position = outside1.position;
stringToEdit = GUI.TextArea (Rect (800, 100, 100, 100), stringToEdit, 200);
Camera.main.transform.position = CameraBlack.position;

doesn’t make any sense because if you get rid of the stringtoedit

transform.position = outside1.position;
Camera.main.transform.position = CameraBlack.position;

if this script is attached to the main camera. your moving it then right away moving it again. hence the double move problem.

mark if answered reply if not.

this script is not attached to the camera. it is attached to the object that moves to “outside1” in the part you referenced. the script tells the object itself to move to a certain location on the click of a button, but it also tells the camera to move to a position. then on a second click of the button, both the camera and object move back to the original spots. I want to be able to do this for a total of 5 objects. I have the script working on one object with the camera moving. but when i add the script to a new object and change the variables to match the object it is applied to, the camera does the flashy thing where it quickly flashes to where i want it, then back to the original position. everything else works fine. its just the camera on the second object.