Get Position of clicked object

Hi there,
i’m new to unity scripting.
I’d like to script something that returns me the position of a clicked object.

I currently have

function OnMouseDown()
{
	pos=GetComponent.(Transform).Translate;
	Debug.Log(pos);
}

Which returns (null). however, I want a vector3 with the coordinates :confused:

I think what you are trying to do here is this-

function OnMouseDown()
{
    var pos : Vector3 = transform.position;
    Debug.Log(pos);
}

Transform.Translate does not return a value- it should be used to move a transform, not to query its position.

Of course, this script only works on one object at a time- to get the position of a clicked object in a more general way, you would use Camera.ScreenPointToRay and Physics.Raycast.

hi again.

unfortunately, i’m getting the error message: BCE0043: Unexpected token: :. on the line

		pos : Vector3 = transform.position;