Disabling/Enabling Scripts

Through inventorymanager script, (the code that is attached) I am working on enabling/disabling 2 otherscripts, enemy damage and enemy police.
I have tried both ways of checking to see if the condition is true (enabling scripts) and checking to see if the condition is false (disabling scripts). These scripts don’t disable or enable.

I have also set a debug for the condition to make sure it switches and also for whether the 2 other scripts (enemy damage and enemy police) are referenced correctly or not. Both of these work.

I’m not sure what I’m doing wrong, but isn’t this how you disable a script? (This is enabled true in the inspector)

function Update () {														
	if (keep_track_attack == false) {
	enemy_damage_reference.enabled = false; 
	enemy_police_reference.enabled = false;
	}

No, that’s not how you access scripts… (unless you’ve declared them as variables somewhere else in your script?)

Normally you’d use GetComponent

Enabled = true works; when the condition is met, both scripts, EnemyPoliceGuy and EnemyDamage are enabled. However, Enabled = false does not work; when the condition is false, enabled is still set to true. How can I fix this?

function Update () {														
	if (keep_track_attack == true) {
	GameObject.FindWithTag("CopperEnable").GetComponent("EnemyPoliceGuy").enabled=true;
	GameObject.FindWithTag("CopperEnable").GetComponent("EnemyDamage").enabled=true;
	}
	if (keep_track_attack == false) {
	GameObject.FindWithTag("CopperEnable").GetComponent("EnemyPoliceGuy").enabled=false;
	GameObject.FindWithTag("CopperEnable").GetComponent("EnemyDamage").enabled=false;	
	}

You don’t need to check for both conditions, just do if/else.

–Eric

I did do the if/else, it’s still not disabling the 2 scripts.