[Closed] Player Weapons Destroying Dont Destroy Confused.

hey everybody so I have an FPS shooter where there are weapons under a single weapons family under a single FPS Shooter called “ASHOOTER”. A few of the weapons have the DontDestroyOnLoad Function because they aren’t a part of the Shooter Prefab. They have this function because when you buy them in the upgrades store they are instantiated and stay throughout the game and get AutoChilded to the weapons family. (Still with me?)

The thing is, when I’m shooting with a different weapon then they are inactive. So That means if I go to the next level while they are inactive, they get destroyed! Is there a way to keep them undestroyed if they are inactive when going to the next level? Let me know if you need clarification. This is my weapons select script:

function Start () {
 // Select the first weapon
 SelectWeapon(0);
}

function Update () {
 // Did the user press fire?
 if (Input.GetButton ("Fire1"))
 BroadcastMessage("Fire");
 
 if (Input.GetKeyDown("1")) {
 SelectWeapon(0);
 } 
 else if (Input.GetKeyDown("2")) {
 SelectWeapon(1);
 }
 else if (Input.GetKeyDown("3")) {
 SelectWeapon(2);
 }
 else if (Input.GetKeyDown("4")) {
 SelectWeapon(3);
 }
 else if (Input.GetKeyDown("5")) {
 SelectWeapon(4);
 }
 else if (Input.GetKeyDown("6")) {
 SelectWeapon(5);
 } 
}

function SelectWeapon (index : int) {
 for (var i=0;i<transform.childCount;i++) {
 // Activate the selected weapon
 if (i == index)
 transform.GetChild(i).gameObject.SetActiveRecursively(true);
 // Deactivate all other weapons
 else
 transform.GetChild(i).gameObject.SetActiveRecursively(false);
 }
}

I tried attaching something like this to my teleporter (that takes you to the next level on trigger, but the weapons still get deletes)

var scriptname : PlayerWeapons;

function Start(){
scriptname = GameObject.Find("Weapons").GetComponent(PlayerWeapons);
}
function OnTriggerEnter (other : Collider){
scriptname.enabled = false;
    Application.LoadLevel ("phosphour");
}

This includes stuff for a different question, and the store scripts are slightly wonky, so just pretend that i fixed them (because i did) but i describe what happens there:

(this is precisely why i asked that other Unity Live Question so It would be easier to explain…)

Replace The Teleporters Scripts Code With This Code:

var myWeaponsObj : GameObject;

function Start()

{

    myWeaponsObj = GameObject.Find("Weapons");

}

function OnTriggerEnter (other : Collider)

{

     myWeaponsObj.SetActiveRecursively(true);
     Application.LoadLevel ("phosphour");

}

You need to be using a public tag on your gun variables so they can be read through more than one scene.