NullReference Exception BurgZerg Arcade

There is a NullReference Exception and I don’t know what to do, please help me!
I am using BurgZerg Arcade RPG hack and slash tut (video here: http://www.youtube.com/watch?v=yXhJgkSiNdw)
GameSetting Script

    using UnityEngine;
    using System.Collections;
    
    public class GameSettings : MonoBehaviour {
    	
    	
    	void Awake(){
    		DontDestroyOnLoad(this);
    	}
    	
    	// Use this for initialization
    	void Start () {
    	
    	}
    	
    	// Update is called once per frame
    	void Update () {
    	
    	}
    	
    	public void SaveCharacterData(){
    	GameObject pc = GameObject.Find("Player");
    
    	PlayerCharacter pcClass = GetComponent<PlayerCharacter>();
    
    	PlayerPrefs.SetString("Player", pcClass.Name);
    
    	}
    
    	public void LoadCharacterData(){
    	}
    }

CharacterGenerator Script

    using UnityEngine;
    using System.Collections;
    using System;				//used for enum class
    
    public class CharacterGenerator : MonoBehaviour {
    	private PlayerCharacter _toon;
    	private const int STARTING_POINTS = 350;
    	private const int MIN_STARTING_ATTRIBUTE_VAULE = 10;
    	private const int STARTING_VALUE = 50;
    	private int pointsLeft;
    	
    	private const int OFFSET = 5;
    	private const int LINE_HEIGHT = 25;
    	
    	private const int STAT_LABEL_WIDTH = 100;
    	private const int BASEVALUE_LABEL_WIDTH = 40;
    	private const int BUTTON_WIDTH = 23;
    	private const int BUTTON_HEIGHT = 23;
    	
    	public GameObject playerPrefab;
    	
    		
    		
    	// Use this for initialization
    	void Start () {
    		GameObject pc = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) as GameObject;
    		pc.name = "Player";
    		
    		
    //		_toon = new PlayerCharacter();
    //		_toon.Awake();
    		_toon = pc.GetComponent<PlayerCharacter>();
    		
    		pointsLeft = STARTING_POINTS;
    		
    		for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
    			_toon.GetPrimaryAttribute(cnt).BaseValue = MIN_STARTING_ATTRIBUTE_VAULE;
    			_toon.StatUpdate();
    		}
    	}
    	
    	// Update is called once per frame
    	void Update () {
    	
    	}
    	
    	void OnGUI() {
    		DisplayName();
    		DisplayPointsLeft();
    		DisplayAttributes();
    		DisplayVitals();
    		DisplaySkills();
    		
    		DisplayCreateButton();
    	}
    	
    	private void DisplayName(){
    		GUI.Label(new Rect(10, 10,50, 25), "Name: ");
    		_toon.Name = GUI.TextField(new Rect(65, 10, 100, 25), _toon.Name);
    	}
    	private void DisplayAttributes(){
    		for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
    		GUI.Label(new Rect(OFFSET, 40 + (cnt * LINE_HEIGHT), STAT_LABEL_WIDTH, LINE_HEIGHT), ((AttributeName)cnt).ToString());
    		GUI.Label(new Rect(STAT_LABEL_WIDTH + OFFSET, 40 + (cnt * LINE_HEIGHT), BASEVALUE_LABEL_WIDTH, LINE_HEIGHT), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());	
    		if(GUI.Button(new Rect(150, 40 + (cnt * 25), BUTTON_WIDTH, BUTTON_HEIGHT), "-")){
    			if(_toon.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VAULE){
    				_toon.GetPrimaryAttribute(cnt).BaseValue--;
    					pointsLeft++;
    					_toon.StatUpdate();
    			}		
    		}
    		if(GUI.Button(new Rect(180, 40 + (cnt * 25), BUTTON_WIDTH, BUTTON_HEIGHT), "+")){
    			if(pointsLeft > 0){
    					_toon.GetPrimaryAttribute(cnt).BaseValue++;
    					pointsLeft--;
    					_toon.StatUpdate();
    				}
    			}
    		}
    	}
    	private void DisplayVitals() {
    		for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
    		GUI.Label(new Rect(OFFSET, 40 + ((cnt + 7) * LINE_HEIGHT), STAT_LABEL_WIDTH, LINE_HEIGHT), ((VitalName)cnt).ToString());
    		GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH, 40 + ((cnt + 7)* LINE_HEIGHT), BASEVALUE_LABEL_WIDTH, 25), _toon.GetVital(cnt).AdjustedBaseValue.ToString());	
    		}
    	}
    	private void DisplaySkills() {
    		for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
    		GUI.Label(new Rect(250, 40 + (cnt * LINE_HEIGHT), STAT_LABEL_WIDTH, LINE_HEIGHT), ((SkillName)cnt).ToString());
    		GUI.Label(new Rect(355, 40 + (cnt * LINE_HEIGHT), BASEVALUE_LABEL_WIDTH, LINE_HEIGHT), _toon.GetSkill(cnt).AdjustedBaseValue.ToString());	
    		}
    	}
    	private void DisplayPointsLeft() {
    	GUI.Label(new Rect(250, 10, 150, 25), "Points Left: " + pointsLeft.ToString());
    	}
    	private void DisplayCreateButton(){
    		GUI.Button(new Rect(Screen.width / 2 - 50, 40 + (10 * LINE_HEIGHT), 100, LINE_HEIGHT), "Create");
    	}
    }

On what line are you getting the null reference?

And please use the CODE tags so that we see the line numbers directly in your post.

Here is a link how to use them:

http://forum.unity3d.com/threads/143875-Using-code-tags-properly

I did sorry,

I am getting the error on line 59 of the CharacterGenerator script.

wasn’t it like this

public void SaveCharacterData(){
        GameObject pc = GameObject.Find("Player");
        PlayerCharacter pcClass = pc.GetComponent<PlayerCharacter>();

instead of

public void SaveCharacterData(){
        GameObject pc = GameObject.Find("Player");
        PlayerCharacter pcClass = GetComponent<PlayerCharacter>();

I am still getting an error.

edit, i should learn how to read. sorry.

I see that the _toon is giving you issues. Are you sure that the PlayerCharacter script is added to the player prefab?
Though that should give errors in earlier lines as well…

Could you maybe post the exact error from the console?

Lol I tried putting my character script on the prefab and BOOM it worked!!
Thank you so such dterbeest :slight_smile:
Best of luck in your city building game.