Change Variable on Another Script

I have 2 scripts running in my game, one attached to a transform (spawnHandler) called “RandomSpawnRandomLocation”

#pragma strict

var spawnPoint : Transform[]; // Create list of possible spawn locations
var wepType : GameObject[]; // Creat list of possible weapons to be spawned
var wepPresent : boolean = false;

function Start()
{
	SpawnWeapons(); //Run SpawnWeapons coroutine
}

function Update()
{
	if(wepPresent == false) //Check to see if weapon is present
		{
			SpawnWeapons(); //If no weapon is present run SpawnWeapons coroutine
		}
}
 
function SpawnWeapons() //Spawns a random weapon at one of possible spawn locations
{
    var randomLoc : int = Random.Range(0,4); //Pick random number between 1 and 4
    var randomWep : int = Random.Range(0,4); //Pick random number between 1 and 4
    
    Instantiate(wepType[randomWep], spawnPoint[randomLoc].position, spawnPoint[randomLoc].rotation);
    //Pick random weapon depending on which number was generated by 'randomWep'
    //Spawn weapon at location depending on which number was generated by 'randomLoc'
    
    wepPresent = true;
}

The other is a simple self destruct script attached to the gameObjects/prefabs that get spawned - “DestroySelfOnContact”
(the objects this script is attached to are prefabs and get spawned/destroyed multiple times)

#pragma strict

function OnTriggerEnter()
{
    Destroy (gameObject);
}

How do I get the DestroySelfOnContact script to change the ‘wepPresent’ variable on the RandomSpawnRandomLocation script ?

Would I be better off having the destroy script attached to my player object as that is always present in the scene ?

???

Sorry i’m not good at javaScript but you can easily find javascript equivalent.

in DestroySelfOnContact script you can

RandomSpawnRandomLocation otherScript;
void Start(){
    otherScript = GameObject.find("spawnHandler").GetComponent<RandomSpawnRandomLocation>();
}

void OnTriggerEnter()
{
    Destroy (gameObject);
    // now you can do otherScript.wepPresent = false/true
}

First create an Object to the script, I will quote the other person’s reply as a reference.

Modify the above idea, make the var as public .

public var randomWeaponRandomLocation : RandomWeaponRandomLocation;

Check if the gameobject is assigned, if its assigned properly, then make sure you change the value before you destroy the object