select a gameObject

I have a gameObject and attached another empty gameObject to it and I want to move it with code. But how do I select the empty gameObject and store it in some variable so I can set some transform.Translate?
I tried FindGameObjectsWithTag and added a tag to the empty gameObject.
But when I try to call it in a function it says:

Unknown identifier: ‘punchObject’.

here is part of my example code:

`function Start () {

var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("punchObject"); 
var punchObject:GameObject = gos[0];

}

function punchNormal(){

punchObject.transform.Translate(Vector2(10,0));

}`

Is there an easy way to just say I want that object and store it in a variable?

You have to set the empty gameObject under the tag of punchObject. Thats the only thing I could see being the problem.

The ‘var punchObject’ inside Start() is a local variable that only lives during the time Start() is running. If you have another class variable at the top of the file with the same name, the local variable is hiding the class variable. You need to remove the ‘var’ from in front of ‘punchObject’. You code should be structured like this:

var punchObject : GameObject;

function Start () {
    var gos : GameObject[];
    gos = GameObject.FindGameObjectsWithTag("punchObject"); 
    punchObject = gos[0];
}

function punchNormal(){
    punchObject.transform.Translate(Vector2(10,0));
}