I am having trouble getting a component of a GameObject.

Every time i put

var Player : GameObject;
var Controls : component;
function Start () {
   Player = GameObject.Find("Player");
   Controls = Player.GetComponent("Controls");
}

the script is named Controls and it is on the Player GameObject.
it will find the Player, but will not find the Controls Script.

I need it to change the Score the player has.

2 Answers

2

Controls = Player.GetComponent(Controls);
as type, not a string, if that still doesn’t work, then I’m personally lost :wink:
http://unity3d.com/support/documentation/ScriptReference/GameObject.GetComponent.html

Wow, made a big beginner mistake. xD Controls was on Main Camera, not Player. xP