GUI buttons do not respond to left click

I am working a GUI that displays a pop up window with buttons whenever I hit a certain object with raycasting. I am able to select the object, disable the raycasting, stop the character controller and movement, and free the cursor. Now when I go to select on of these buttons in my GUI window, only right clicking and the middle mouse button click will actually do anything. Left clicking just reverts my cursor to the middle of the screen. Any idea on what is causing this and how to fix it?

function OnGUI() {

if (Options == true) { // Changed from another script 
	StopForGUI(); // Disables mouse look scripts
	GUI.Window(0,Rect(Screen.width / 2 - 100, 100 , 200, 400), OptionsWindow, "Options"); // Call options window
}
}

function OptionsWindow (windowID : int) {
	GUI.BringWindowToFront(windowID); 
	GUI.FocusWindow(windowID);
	if (GUI.Button (Rect (25, 75, 150, 40), "Selection 1")) {
		print ("");
		Options = false; // Turns the window off after a selection
		Resume();  // Re-enables character controllers and movement
	}
	if (GUI.Button (Rect (25, 125, 150, 40), "Selection 2")) {
		print ("");
		Options = false;
		Resume();
	}
	if (GUI.Button (Rect (25, 175, 150, 40), "Selection 3")) {
		print ("");
		Options = false;
		Resume();
	}
	if (GUI.Button (Rect (25, 225, 150, 40), "Exit")) {
		print ("Exit");
		Options = false;
		Resume();
	}

}

 // Stops the game and unlocks the cursor
function StopForGUI() {
	player.GetComponent(FP_SelectObject).enabled = false; //Disables raycasting script
	Screen.lockCursor = false; 
	player.GetComponent(MouseLook).enabled = false;
	player.GetComponent(CharacterMotor).enabled = false;
	mainCamera.GetComponent(MouseLook).enabled = false;
	//Time.timeScale = 0.0;
}
// Resumes the game and locks the cursor
function Resume() {
	player.GetComponent(FP_SelectObject).enabled = true;
	player.GetComponent(MouseLook).enabled = true;
	player.GetComponent(CharacterMotor).enabled = true;
	mainCamera.GetComponent(MouseLook).enabled = true;
	Screen.lockCursor = true;
	//Time.timeScale = 1.0;
}

Thanks,

dylan92

This is how you take care of each click on your button:

if (GUI.Button (Rect(10,20,100,20), "Selection 1"))
{
	var event : Event = Event.current;
	
	if(event.button == 0 && event.isMouse) {
    	Debug.Log("Left Click");
	} else if(event.button == 1) {
    	Debug.Log("Right Click");
	} else if (event.button == 2) {
    	Debug.Log("Middle Click");    
	} else if (event.button > 2) {
    	Debug.Log("Other buttons on your mouse were clicked");
	}
}

But this will probably not help you with the repositioning of the cursor. I think we have to see some of your code to help you with that.