Difficulties accessing camera rotation

Hi,

I’m trying to make a simple player controller. For various reasons the standard one just won’t do. I’ve pulled in a stock script for camera movement, but now I need to access the rotation of the camera and use it to change the rotation of the player, so that when you move the mouse, the whole player rotates. I’ve used scripts to find game objects before and haven’t had any issues, but this script just doesn’t want to work.

var camera : GameObject = GameObject.Find("Camera");

(This would be UnityScript)
For some reason the script doesn’t report any bugs with this code on its own, but as soon as I try to do something with the GameObject camera in the actual script function, I get the error message

“Ambiguous reference ‘camera’”

Am I doing something wrong?

EDIT:

I’ve been trying to access a simple rigidbody Cube, instead. Again, Unity doesn’t seem to have a problem with the declaration of the GameObject variable itself, but whenever I try to do something with it, it tells me that the variable ‘cube’ has not been assigned, or returns null.

var cube : GameObject = GameObject.Find("Cube");

function FixedUpdate()
{
	
	if(Input.GetKey("w"))	// Forwards.
	{
		//transform.Translate(0, 0, 0.1);
		Debug.Log(cube.ActiveInHierarchy);
		cube.rigidbody.AddForce(Vector3.up * 100);
	}

You appear to be trying to run a command outside of any function. Outside of functions you can only declare variables - for anything that you want to happen while your game is running, you have to define when.

var cube : GameObject;

function Start()
{
    cube = GameObject.Find("Cube");
}