keep function from running until completion

I have a rotation script that activates if you left or right click the mouse. The problem is that if I click too fast My rotating object goes crazy. Is there a way to keep mouse click from working while my rotation script is already running?

You want to use a boolean function, but its hard to tell ... please upload your script

private var isRotating = false;

function Whatever () {
    if (isRotating) return;
    isRotating = true;
    // stuff
    isRotating = false;