GameObject.Find Dont work

Hello i have a game where you need to create your own axe to be able to cut down trees (the basic you know). But i have some problems, first you need a stone and a sitck to be able to craft it. When you have crafted it, it wil spawn infront of you (a prefab). Then i have an axe on my main camera that is going to dislay when i rightclick on the axe on the ground. Here comes the problem, my axe that spawns is a prefab, and my axe in the hand (that is going to display) is a gameobject, and as you know a prefab can not see a gameobject in the scene, so thats why i added a line in my code :

function Update ()
{
	StoneAxeInHandObj = GameObject.Find("StoneAxeInHand");
}

So when ever the axe spawns in the scene it will find where the axe in the hand. But when i try my game it still doesn’t work, it still doesn’t fill in the “StoneAxeInHandObj”. What is the reason? I have that line of code in the Update function?

Rest of “pickUpStoneAxe” Script:

#pragma strict

var style : GUIStyle;
var StoneAxeInHandObj : GameObject;

private var showPickUp : boolean = false;

function Update ()
{
	StoneAxeInHandObj = GameObject.Find("StoneAxeInHand");
}

function Start ()
{
	StoneAxeInHandObj.SetActive(false);
}

function OnTriggerStay (Col : Collider)
{
	if(Col.tag == "Player")
	{
		showPickUp = true;
	}
	
	if(Col.tag == "Player" && Input.GetMouseButtonDown(1))
	{
		StoneAxeInHandObj.SetActive(true);
		Destroy(gameObject);
	}
}

function OnTriggerExit (Col : Collider)
{
	if(Col.tag == "Player")
	{
		showPickUp = false;
	}
}

function OnGUI ()
{
	if(showPickUp == true)
	{
		GUI.contentColor = Color.red;
		GUI.Label(new Rect(650, 650, 200, 50), "Right click to pick up a StoneAxe", style);
	}
}

hi there,

From what i understand, .Findbytag is better than .Find and at some stage down the track you should consider placing the object into a variable and using the variable in the Update(). Doing this will be much better than looking it up constantly.

private GameObject theObject;

//in start()

theObject = GameObject.Find("yourAxeName");

//in update()
///your code goes here
//eg:
theObject.SetActive(false);

I think it might have to do with the execution order.

The OnTriggerStay is executed before the Update.
You try to set StoneAxeInHandObj active, but it is not assigned yet.
After the SetActive you destroy the gameobject.
I assume the Update is never reached.