Script is changing default values

When I do it this way

for(var i : int = 0;i < (possibles.Length);i++)
{
possibleScripts _= possibles*.gameObject.GetComponent("GunScript");*_

possibleScripts_.cashPrice = possiblesCosts*;
(((possibleScripts.shotMaxDamage + possibleScripts.shotMinDamage)/2) * (possibleScripts.ammo ) (2.65 ))+ (PlayerScores.difficulty * 12);

}
isntead of
doScript = currentGun.gameObject.GetComponent(“GunScript”);
doScript.cashPrice = possiblesCosts[gunToPick];
it changes the values of the prefab associated, instead of just the instance. Is this because the guns are added into an array beforeHand, and are thus just referencing the prefabs? If so is there a way I can pre spawn them?
I mean, this works, but it seems “Less correct”._

It is because the guns are not instantiated and you just modifying the prefabs.

You may instantiate the game objects and deactivate them so they are in the hierarchy but act like they do not exist or you can keep those values in a structure always present and when you instantiate a gun from its prefab you give it the data structure for it.

I figured as much. I will code in that direction first I guess. Test it out and see how it behaves compared to the current functioning method.
Thanks Tourist.