Problem with getting component, help please? ^^'

Hi I’ve got some trouble lately trying to use getcomponent.

Could I have some information on what makes my C# script not working please? ^^’

static Component skillLvlVal;
static Component skillCurVal;

void GetValues() {
	skillLvlVal = transform.parent.gameObject.GetComponent("LvlVal");
	skillCurVal = transform.parent.gameObject.GetComponent("CurVal");

static int lvlVal = int.Parse(skillLvlVal.GetComponent<GUIText>().text);

public static int currentVal = int.Parse(skillCurVal.GetComponent<GUIText>().text);

static int minHp;
static int maxHp;
static int hp;

static void Start () {
	minHp = 0;
	maxHp = lvlVal;
	hp = maxHp;

This is only a part of the script, but the rest isn’t necessary as it’s not yet using those values, but will as soon the error is fixed ^^.

Basically I’m trying to get a component (LvlVal and CurVal) from the script parent.
But when calling it, it gives me an “Object not set to an instance of an Object.” for each of the two Values.

This script is to make a basic Skill tree. (Here’s the screen shot to show what it looks like, I got a button on the second button (second in the top row))

Here’s how the button looks like, the CurVal is the top number and the lvlVal is the bottom one.

Could I get some help with that please ? ^^

This line gives you an “object not set to an instance of an object”?

skillLvlVal = transform.parent.gameObject.GetComponent("LvlVal");

That would suggest that the object to which this script is attached does not have a parent.

As a separate issue though, you seem to be making all your variables static- why is that? It’s undoubtably going to cause you troubles later on.