AddComponent can't seem to find any of my scripts

I’m having some troubles with AddComponent as every time I try to use it, it doesn’t seem to work, or be able to find the script that I’m trying to add to a gameobject. I have no idea why this isn’t working, thus I’m seeking advice with you guys.


Part of my code that isn’t working (Plus a couple of lines that is):

GameObject player = GameObject.CreatePrimitive (PrimitiveType.Cube);
player.transform.position = new Vector3 (0, worldHeight, -0.1f);
player.renderer.material.color =; = "Player";
player.AddComponent ("Player");

GameObject.Find ("Main Camera").AddComponent("CamControl");

So far I’ve got these three files:

  • GenerateMap.cs
  • CamControl.cs
  • Player.cs

if you want to attach a script to a gameobject by his name
us this

GameObject.Find("Main Camera").AddComponent<CamControl>();