Enabling script

i want a script to be disabled until a target is selected heres the script that selects a target

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Movement : MonoBehaviour {

public Transform selectedTarget;

  void Update(){
    if (Input.GetMouseButtonUp(1)){ // when button clicked...
      RaycastHit hit; // cast a ray from mouse pointer:
      Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
      // if enemy hit...
      if (Physics.Raycast(ray, out hit) && hit.transform.CompareTag("Enemy")){
       
        selectedTarget = hit.transform; // set the new one...
        SelectTarget(); // and select it
      


 }
        }
      }
   private void SelectTarget(){
        Movement2 m = (Movement2)GetComponent("Movement2");
   m.target = selectedTarget.transform;
    }
    } 

the script i want disabled is just a script that makes the heroes move to the target and when this script selects that target the other script becomes enabled and moves to the target how would i go about doing this. Thanks in advance

You can use something like this, if the target is selected then get the component that has the script you want to disable. To do so use the following once the target is selected

GameObject.Find(" put the name ofthe object that has the script").GetComponent("the script name").enabled = false;

That seems a bitmore of beating around the bush… just make an if statment that says something like

if (target selected = “thing you want”){

do something;

}

this way the script is running but nothing will happen until u select the target…