making an RPG

I have another post on here and I got some help with an error. Now when I run my game I get a new error this
is the error: Object reference not set to an instance of an object
Controller.Start () (at Assets/scripts/Controller.cs:13)

using UnityEngine;
using System.Collections;

public class Controller : MonoBehaviour{
	
	public PlayerStats _jake;
	
	
	
	void Start(){
		
	_jake = GetComponent<PlayerStats>();
	_jake.level = 3;  //This is where the error shows me.
	_jake.name = "Jake";
	_jake.STR = 50;
        _jake.DEX = 55;
        _jake.DEF = 50;
        _jake.vital = 100;
        _jake.Magic = 60;
        _jake.luck = 45;
        _jake.Speed = 56;
        _jake.Agility = 46;
        _jake.exp.Cur = 0;

			
	}
	
}

any help would be great Thanks

these my rpg characters that need the PlayerStats class: Jake, Amy, Cole, Lily, and Max. The are the names I am using for the
rpg game.

That error means that GetComponent cannot find any component named PlayerStats. Did you add the PlayerStats component to the game object?

You can test to be sure by using this code:

void Start()
{
   _jake = GetComponent<PlayerStats>();

   if (!_jake) // If _jake == null
   {
      Debug.Log("No PlayerStats component found!");
      return;
   }
   _jake.level = 3;  //This is where the error shows me.
   _jake.name = "Jake";
   _jake.STR = 50;
   _jake.DEX = 55;
   _jake.DEF = 50;
   _jake.vital = 100;
   _jake.Magic = 60;
   _jake.luck = 45;
   _jake.Speed = 56;
   _jake.Agility = 46;
   _jake.exp.Cur = 0;
}

Another thing you might find useful is adding a RequireComponent attribute to the top of your monobehaviour.

[RequireComponent(typeof(PlayerStats))]
public class Controller : MonoBehaviour
{
   //...
}

This will force the editor to add a PlayerStats component to any GameObject that you add Controller to.

Thanks for the tip but I guess I should have said my playerstats class is not monobehaviour sorry about that
here is what my PlayerStats class that derives from controller

public class PlayerStats : Controller {

public int level;
public string name;
public Stat Hp = new Stat();
public Stat Mp = new Stat();

public int STR;
public int DEX;
public int DEF;
public int vital;
public int Magic;
public int luck;
public int Speed;
public int Agility;

public int melee;
public int ranged;
public int MagA;
public int MagD;
public float active;

public Stat exp = new Stat();

public void addexp(int ex){

exp.Cur += ex;
while(exp.Cur >= exp.Max level < 99){
exp.Cur -= exp.Max;
exp.Max = level (level+1) 500;
level++;
upstats();
}

}

void upstats(){
STR++;
DEX++;
DEF++;
vital++;
Magic++;
luck++;
Speed++;
Agility++;

melee =(level7)+STR;
ranged =(level
7)+DEX;
DEF =(level2)+ Agility;
MagA =(level
7)+ Magic;
MagD =(level*2)+ luck;

active =20+((Speed * level)/1500);

Hp.Max =((level * 5)+ vital)*10;
Hp.Cur = Hp.Max;
Mp.Max =((level * 5)+ Magic)*10;
Mp.Cur = Mp.Max;

}

public class Stat{
public int Cur;
public int Max;

}

public PlayerStats(int level,string name,int STR,int DEX,int DEF,int vital,int Magic,int luck,int speed,int Agility,int exp){
this.level = 1;
this.name = name;
this.STR = STR;
this.DEF = DEF;
this.vital = vital;
this.Magic = Magic;
this.luck = luck;
this.Speed = speed;
this.Agility = Agility;
addexp(exp);
}
}

do I also need to have the line [RequireComponent(typeof(PlayerStats))] in this class too?

If PlayerStats derives from Controller, then it does derive from Monobehaviour. Example-

Vehicle : Monobehaviour
Car : Vehicle
Bike : Vehicle
Mercedes : Car

If you want your stats to be like a list of variables inside your Controller, don’t have it derive from anything. Then you can also completely take out the GetComponent() line.

public class PlayerStats {
	//Like this ^
	//Keep everything else the same.
}

void Start() {
    //  Take this line out.  --->_jake = GetComponent<PlayerStats>();
	
	// Now, PlayerStats is not a component, but a variable.
	// You can edit its own variables here:
    _jake.level = 3;
    _jake.name = "Jake";
    _jake.STR = 50;
    _jake.DEX = 55;
    _jake.DEF = 50;
    _jake.vital = 100;
    _jake.Magic = 60;
    _jake.luck = 45;
    _jake.Speed = 56;
    _jake.Agility = 46;
    _jake.exp.Cur = 0;
}

thanks alot for helping me and do I make all 5 of my characters like this because the stats change every
time you level up so you start the game at level 3 and then you level up by battling monsters or students
(Because this game is a rpg) so variables will change
on each levelup?I need to know what to do about leveling up all of my characters in my game?

when I put the controller script on my camera it says Stack Overflow Exstition then frezze