how to get a gameObject's name from another scrpit

I have read Overview: Accessing Other Game Objects

but could not get the concept

//in ProjectileManager.js script

var projectile : GameObject ; 

function Start () {

projectile  = AssetDatabase.LoadAssetAtPath( "Assets/cannonball.prefab", typeof(GameObject) );
}

I need to know what is assigned to the projectile in ProjectileManager.js While coding in the GunType.js

//My wrong GunType.js file

internal var gunName : Projectile;
 gunName = GetComponent(Projectile);

function Start () {

}

function Update () {
	print(gunName.projectile.transform.name + "from GUI");
}

I need to have access to name of the gameObject assigned to projectile, (in this case “cannonball”)

it should be an easy situation, hope you can help :frowning:

You need to find GameObject thet script assained to. Then find script it self, and then get var. You do it like this:

private var projectile_manager: Component;
projectile_manager = GameObject.Find("Name of game object script assaingt to").GetComponent(ProjectileManager);
private var Projectile : GameObject;

Projectile = projectile_manager.Projectile;

Or you can predefine GameObject script attach to;

    private var projectile_manager : Component;
    var projectileScriptObject : GameObject;
    projectile_manager = projectileScriptObject.GetComponent(ProjectileManager);
    private var Projectile : GameObject;
    
    Projectile = projectile_manager.Projectile;