How can i make GetButton only fire once?

enter code hereOkay so basically, i have 2 objects, both with cameras, and right now im using Input.GetButton(“Fire1”) to check to see if one of the objects was clicked. It works but when im pressing mouse button its reading getbutton like 4 or 5 times resulting in weird behavior. so my question is, how an i make it so that this betbutton call will only return once per click? GetButtonDown(“Fire1”) does not work.

using UnityEngine;
using System.Collections;

public class CameraControl : MonoBehaviour {
    
    
	public Transform target;
	public Vector3 position;
	public float rotateSpeed = .01f;	
	public float distance = 2.8f;
	public float xSpeed = 250.0f;
	public float ySpeed = 120.0f;
	public float yMinLimit = -80;
	public float yMaxLimit = 80;
	public float x = 0.0f;
	public float y = 0.0f;
	public Vector3 distanceVector;
	
	
	public Camera curCam;
	public Camera tarCam;
	
	
	
	void CameraSelect() {
		//Debug.Log("1");
		curCam = Camera.current;
		//Debug.Log("2");
		if(Input.GetButton("Fire1")){
			Debug.Log("3");
			RaycastHit rayHit;
			Ray ray = Camera.current.ScreenPointToRay(Input.mousePosition);
			Debug.Log("4");
			if (Physics.Raycast(ray, out rayHit, 1000)){
				Debug.Log("5");
				curCam.enabled = false;			
				tarCam = rayHit.transform.gameObject.GetComponentInChildren< Camera >();
				tarCam.enabled = true;
			}
		}
	}
	
	// Use this for initialization
	void Start () {
		
    	x = transform.eulerAngles.y;
    	y = transform.eulerAngles.x;
		distanceVector = new Vector3(0,0,-distance);
		
		if (rigidbody)
		rigidbody.freezeRotation = true;
		
	}
	
	// Update is called once per frame
	void Update () {
		CameraSelect();
		if(target){
			if(Input.GetMouseButton(1)){
				x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
        		y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
 		
 				y = ClampAngle(y, yMinLimit, yMaxLimit);
 		       
        		Quaternion rotation = Quaternion.Euler(y, x, 0);
				Vector3 position = (target.transform.position + (rotation * distanceVector));
        
        
        		transform.rotation = rotation;
        		transform.position = position;
				}
		}
			
			
	}
	static float ClampAngle (float angle, float min, float max) {
	

        if (angle < -360)
            angle += 360;
        if (angle > 360)
    	angle -= 360;
        return Mathf.Clamp (angle, min, max);
    }
}

Found a few issues. You were defining a few things within functions instead of at the top of your script, some one of them twice (position), and you were defining curCam but not using it. Try this.

using UnityEngine;
using System.Collections;

public class CameraControl : MonoBehaviour 
{
	public Transform target;
	public Vector3 position;
	public float rotateSpeed = .01f;
	public float distance = 2.8f;
	public float xSpeed = 250.0f;
	public float ySpeed = 120.0f;
	public float yMinLimit = -80;
	public float yMaxLimit = 80;
	public float x = 0.0f;
	public float y = 0.0f;
	public Vector3 distanceVector;
	public Camera curCam;
	public Camera tarCam;
	RaycastHit rayHit;
	Ray ray;
	Quaternion rotation;
	
	void Update () 
	{
		CameraSelect();
		
		if(curCam != Camera.current)
			curCam = Camera.current;
		
		if(target)
		{
			if(Input.GetMouseButtonDown(1))
			{
				x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
				y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
				y = ClampAngle(y, yMinLimit, yMaxLimit);
				
				rotation = Quaternion.Euler(y, x, 0);
				position = (target.transform.position + (rotation * distanceVector));
				transform.rotation = rotation;
				transform.position = position;
			}
		}
	}
	
	
	void CameraSelect() 
	{
		if(Input.GetButtonDown("Fire1"))
		{
			Debug.Log("3");
			
			if(curCam != null)
				ray = curCam.ScreenPointToRay(Input.mousePosition);
			
			Debug.Log("4");
			
			if (Physics.Raycast(ray, out rayHit, 1000))
			{
				Debug.Log("5");
				curCam.enabled = false;
				tarCam = rayHit.transform.gameObject.GetComponentInChildren< Camera >();
				tarCam.enabled = true;
			}
		}
	}
	
	// Use this for initialization
	void Start () 
	{
		x = transform.eulerAngles.y;
		y = transform.eulerAngles.x;
		distanceVector = new Vector3(0,0,-distance);
		
		if (rigidbody)
			rigidbody.freezeRotation = true;
	}
	
	// Update is called once per frame
	
		
	static float ClampAngle (float angle, float min, float max) 
	{
		if (angle < -360)
			angle += 360;
		if (angle > 360)
			angle -= 360;
		return Mathf.Clamp (angle, min, max);
	}
}