Refer to object class is attached to

I have a variable inside the weapon class called thisGun that I would like to be set to what ever objects are currently set as the wepaon class.

EX If I had an object called gun1 how would I get the varible thisGun to refer to gun1’s transform or GameObject.

Script attached to the gun Object

var gun : Weapon
 function Start(){

Script that contains the Weapon class (bellow)

class Weapon extends Item{

function SetValues(){   //called at function start on gun Object
var thisGun = this.GameObject;



See: Accessing Other Game Objects.

If I understand you correctly, you probably want a reference to the Weapon component that’s on an object. You can use GetComponent():

var gun : Weapon;

// Get a reference to the first Weapon component found on the game object:
gun = GetComponent(Weapon);

// Always check for null, in case none was found:
if (gun == null) Debug.LogError("No Weapon component found!");

// What the heck, I'm not sure why you'd do this, but
// this sets the Weapon class's thisGun variable to
// point to its own game object, since this component
// is on the same game object:
gun.thisGun = this.gameObject;

I give 50/50 odds that I understand your question correctly. If I totally missed it, read that link above.