My score system doesn't display or work? Please help me!

I am making a game that has a scoring system but it doesn’t work. I am trying to make it where if the enemy dies the player gets 10 points and so on. So, I made a GUIText to display the score and made a script with the following:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Score : MonoBehaviour
{
public GUIText scoreText;
private int score;

void Start()
{
    score = 0;
    Update();
}

public void AddScore(int newScoreValue)
{
    score += newScoreValue;
    Update();
}

void Update()
{
    scoreText.text = "Score: " + score;
}

}
and on the enemy side, I put the next following script so it can die when hit and to scores a point but it doesn’t work.

using UnityEngine;
using System.Collections;

public class Damagebycrash : MonoBehaviour {
int health = 1;
public int scoreValue;
private Score score;

void OnTriggerEnter2D(Collider2D collider)    {
    if(collider.tag == "Invaders"){
        score.AddScore(scoreValue);
    }

    Debug.Log("Trigger!!");

    health--;

    if (health <= 0) {
        Die();
    }
}

void Die()
{
    Destroy(gameObject);
}

}
so yeah please help me?

First of all, “void Update()” method is called at every frame automatically. So there isn’t really need to call Update () in your Start () and AddScore (int value).

Since i am lacking detailed information as to whether what is happening and what is not, I will be relying on my assumption based on the evaluation of only the code you posted.

I assume that enemies will die when collision is triggered. Correct?
But I don’t think your Score variable (private Score score) is assigned to anything yet. Hence, score.AddScore(scoreValue); will not do anything.

Try:

public static void AddScore(int newScoreValue) {
      score += newScoreValue;
}

for your method in Score and you also need to make your score declaration to be “static int score”

void OnTriggerEnter2D(Collider2D collider){
       if(collider.tag == "Invaders") {
            Score.AddScore(scoreValue);
      }
}

for your enemies’ script.

This way, all enemies’ scripts will have access to static method from Score script without having to assign the Score class variable.

Hope this helps : )