How do I access this value properly so my characters exp goes up?

Hey I’ve been trying to get a level up system for skills and I think I’m pretty close to having it setup how I want it. However I am having trouble figuring out how to have my character gain Exp when he chops the tree (Accessing the woodcuttingcurExp from the first script and changing it so it adds 25exp when cutting the tree).

I got 1 Script that is on my character that takes care of his Experience & Leveling system, this is working fine but I posted this so it’d be easier to help me with the problem since I have to access woodcuttingcurExp from here to add 25exp.

THIS SCRIPT IS ATTACHED TO MY PLAYER

Skills2.cs

using UnityEngine;
using System.Collections;

public class Skills2 : MonoBehaviour {


public int woodcuttingCurrentLevel = 1;
public int woodcuttingMaxLevel = 99;

public int woodcuttingcurExp = 1;
public int woodcuttingmaxExp = 100;
	
public float expBarLength;

void Start () {

		expBarLength = Screen.width / 2;

}

void Update () {
		
		AdjustCurrentExp(0);

	if(woodcuttingcurExp >= woodcuttingmaxExp)
	{
		woodcuttingcurExp -= woodcuttingmaxExp;
		woodcuttingCurrentLevel++;
			woodcuttingmaxExp += (20 * woodcuttingCurrentLevel);
		}		

}

void OnGUI()
{
GUI.Box(new Rect(20, 50, 
			//expBarLength "Delete the 200 and put this back in to get moving exp bar
			200, 20), woodcuttingcurExp + " / " + woodcuttingmaxExp);
GUI.Box(new Rect(20, 90, 200, 20), "Level: " + woodcuttingCurrentLevel + " / " + woodcuttingMaxLevel);

	}
	
	public void AdjustCurrentExp(int adjExp)
	{
		woodcuttingcurExp += adjExp;
		
		expBarLength = (Screen.width / 3) * (woodcuttingcurExp / (float) woodcuttingmaxExp);
	}	

}

This is the 2nd script that I have on my object (tree) that allows me to cut it down, the problem I am having is I can’t figure out how to reference the character’s Skills2 Script and get it to add Experience to my characters woodcuttingcurExp.

Here is where I am having the problem, Unity 3D Error says “Unknown identifier skills2”. I have tried quite a few ways to access and change that value but so far haven’t been able to change it. I have tried to access it with the following 2 lines of code as well but haven’t been able to figure out exactly what to type in here.

var player = GameObject.Find(“Player”);

// var skills2: Skills2 = GetComponent(Skills2);

(I get an error when this code above is put in because it’s probably typed in wrong that is why it’s edited out with the 2 // before it)

if(chopping){

         **skills2.woodcuttingcurExp += 25;**

(This line above is the main problem, I can’t figure out how to access and change the woodcuttingcurExp value properly)

Here is the entire 2nd Script where I am having the problem.

THIS SCRIPT IS ATTACHED TO THE TREE OBJECT THAT I WANT TO GAIN EXP FROM WHEN CHOPPED

NormalTree.js

    var duration : float = 5;
    var stumpPrefab : GameObject;
    var stackPrefab : GameObject;
    private var startTime : float = 0;
    private var showGUI : boolean = false;
    private var chopping : boolean = false;
     var treeWoodcuttingLevel : int = 1;
     var XPGainedAfterCuttingDown : int = 25;
     
     
     
    function OnMouseOver () {
        var player = GameObject.Find("Player");
//        var skills2: Skills2 = GetComponent(Skills2);
   		
//    if(Vector3.Distance(GameObject.Find("Player").transform.position, transform.position) > 2.0)
//                return;
        showGUI = true;
        if(Input.GetMouseButtonDown(0)){
            chopping = true;
            startTime=Time.time;
        }
       
    if(chopping){
    
             skills2.woodcuttingcurExp += 25;
//        player.animation.CrossFade("1h_attack1");
        if(Time.time - startTime < duration){
 

            Instantiate(stumpPrefab, transform.position, transform.rotation);
            Instantiate(stackPrefab, transform.position, transform.rotation);
        }
        else{
            chopping  = false;
            Destroy(gameObject);
        }
    }
    }
     
    function OnMouseExit () {
        showGUI = false;
    }
     
    function OnGUI () {
        if(showGUI && !chopping)
            GUI.Label (Rect (10, 10, 100, 20), "Chop down this tree");
    }

If anyone could please show me how to properly access and change this value so my character gains experience when cutting the tree it would be much appreciated, thanks.

You must call GetComponent on particular game object (but with another component works as well):

var skills2: Skills2 = player.GetComponent(Skills2);

And add this line where u want to increase experiance:

skills2.woodcuttingcurExp += XPGainedAfterCuttingDown;