Score count not changing

Hey, I posted my problem on reddit the other day, but I haven’t fixed the problem and I really need it done as soon as possible. If someone could read over the code and see what my problem is i’d really appreciate it.
http://www.reddit.com/r/Unity3D/comments/34e4j6/anyone_help_with_this_score_count_code/

I also found i’m getting this error code now can someone explain this?

NullReferenceException: Object reference not set to an instance of an object
Pickups.SetCountText () (at Assets/Game Scripts/Pickups.cs:40)
Pickups.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Game Scripts/Pickups.cs:33)

Well to answer your error, a NullReferenceException is an error when you’re trying to use something that’s either been set to null by yourself, or it just doesn’t contain anything.

What is that Text variable, is it another script?

Here it worked perfectly

This error is because you did not drag the text to the field of property in the inspector

You must be forgetting to do something in the process

Create a new scene for testing and follow these steps :

  • Create a cube in the scene

  • Attach the script to this cube

  • Drag the text object into the field of property in the inspector

  • Add to the cube the rigidbody component

  • Disable the “Use Gravity” option in rigidbody component

  • Create a sphere

  • Activate the “Is Trigger” on the sphere collider

  • Create the tag “Pick Up”

  • Add this tag to the sphere

  • Press play and control the cube to collide with the ball, if you did everything right it should work

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

public class Pickups : MonoBehaviour
{
    public float speed;
    public Text countText;
   
    private int count;
   
   
    void Start ()
    {
        count = 0;
        SetCountText ();
    }
   
    void FixedUpdate ()
    {
        float moveHorizontal = Input.GetAxis ("Horizontal");
        float moveVertical = Input.GetAxis ("Vertical");
       
        Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

        transform.Translate((movement*10)*Time.deltaTime);
       
    }
   
    void OnTriggerEnter(Collider other)
    {

        if (other.gameObject.CompareTag("Pick Up"))
        {
            Debug.Log("collided");
            count +=1;
            SetCountText ();
            Destroy(other.gameObject);
        }
    }
   
    void SetCountText ()
    {
        countText.text = "Count: " + count.ToString();
    }
}

Denis Lemos