Problem disabling a script

I have a player that moves left to right when i touch on either side of my device. I also have it set up so that the clap animation plays when i touch him. The problem is, when i touch the player, the script for moving left and right is active and so he moves while he claps.

I would like to disable the movement script for the second i touch the player and enable it again after, but as it is at the moment the player still moves when i press on him.

Can anyone point out where I’m wrong? Code below:

using UnityEngine;
using System.Collections;

public class clap : MonoBehaviour 
{

	public LeftRightMovement leftRightScript;

	public AnimationClip clapHand;

	// Use this for initialization
	void Start () 
	{
		leftRightScript = GetComponent<LeftRightMovement>();
		animation.Stop ();
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (Input.GetMouseButtonDown (0)) 
		{

			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			
			RaycastHit hit;
			Debug.Log("hit");
			if(Physics.Raycast (ray, out hit) && hit.collider.gameObject.tag == "Player")
			{
				Debug.Log("hit");
				animation.Play ();
                //The script i want to disable
				leftRightScript.enabled = false;

			}
		}
		leftRightScript.enabled = true;
	}
}

Well, that’s because you reEnable it soon after.

The thing is when you check for the mouse button down, you check only for one frame. That means that once i Click the mouse button, the next frame won’t receive the same event, instead it will suppose that the mouse button hasn’t been pressed this frame, thus reenabling the leftRightScript, even if i hold the button down.
What you should do is either change GetMouseButtonDown with GetMouseButton, that way the script will stay disabled until you release the button, or check for GetMouseButtonUp and reenable the script once the button has been released.

Another solution would be to use a CoRoutine the length of the animation and then reenable the script:

    IEnumerator ReEnableLeftRightScript()
    {
     yield return new WaitForSeconds(animation["Clap"].length);
     leftRightScript.enabled = true;
    }
 void Update () 
    {
        if (Input.GetMouseButtonDown (0)) 
        {
 
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 
            RaycastHit hit;
            Debug.Log("hit");
            if(Physics.Raycast (ray, out hit) && hit.collider.gameObject.tag == "Player")
            {
                Debug.Log("hit");
                animation.Play ();
                //The script i want to disable
                leftRightScript.enabled = false;
                StartCoRoutine(ReEnableLeftRightScript());
            }
        }
      
    }