Enabling and disbaling of scripts through code issue in unity

I’m trying to enable and disable a script through code but the issue is that sometimes the scripts appear to work like they are supposed to but sometimes not i.e sccipts gets turned on even they are supposed to be remain turned off for the specific amount of time Following are the methods i used but none of them working perfectly.

            gameObject.Find("ScriptsHolder").GetComponent (GunFire).enabled =false;
                                                                                                             
              this.GetComponent(GunFire).enabled=false;

here’s the complete script of reloading in which it’s happening if someone wants to take a look to understand the problem

                       if(Input.GetButtonDown("Reload")) {
						if (ReserveCount <= ReloadAvailable) {

		    		anim1.SetBool("Reload",true);
		    		isReloading=true;
gameObject.Find("ScriptsHolder").GetComponent (SecondGunFire).enabled =false;
                                this.GetComponent(SecondGunFire).enabled=false;

 gameObject.Find("ScriptsHolder").GetComponent (On).enabled =false;

			M4GunFire.LoadedAmmo += ReserveCount;
			M4GunFire.CurrentAmmo -= ReserveCount;

			ActionReload();
             		   
		}
		else {
             		   

		anim1.SetBool("Reload",true);
		isReloading=true;
	gameObject.Find("ScriptsHolder").GetComponent (SecondGunFire).enabled =false;
    this.GetComponent(SecondGunFire).enabled=false;

             		   gameObject.Find("ScriptsHolder").GetComponent (On).enabled =false;

			M4GunFire.LoadedAmmo += ReloadAvailable;
			M4GunFire.CurrentAmmo -= ReloadAvailable;

			ActionReload();
		}
	}
                                             
        StartCoroutine(EnableScripts());
ActionReload ();

}

}

      function EnableScripts () {
             yield WaitForSeconds (7);
             		   gameObject.Find("ScriptsHolder").GetComponent (SecondGunFire).enabled =true;
             		  gameObject.Find("ScriptsHolder").GetComponent (On).enabled =true;
	isReloading=false;

}

            function ActionReload () {

                                                          
           ReloadSound.Play();
                        }

UnityScript is no longer supported. You should port your code to C#. If you still use an older Unity version you could continue using it, however there is no further support.

We can’t help you with your specific error because your code is barely readable nor is the description of the problem very detailed. Debugging requires a well understanding of what is supposed to happen and to ovbserve what actually happens. This can only be done by you. When you use terms like “sometimes”, “not working” it’s an indicator you didn’t pay enough attention to analyze your issue. We can help you to interpret your findings but we can’t do the debugging for you.

I’m not sure how important this is, but I’m not sure if the formatting you’re using is correct.

You are using the format:

GetComponent (COMPONENT_NAME)

… instead of what I believe should be …

GetComponent<COMPONENT_NAME>()

That’d be my first guess. Good luck!

Here’s some relevant documentation.