Get Component Error C#

Hey,

I’m only a beginner and have probably made a mistake so any help would be appreciated.

I made a game where there is a slime, and it randomly moves around and when you get close it sometimes attacks you by moving towards you.

Also if you click on the slime it tells you about it.

I tried all of this and it worked but then I needed to make it a prefab and the inspector connections disappeared, so I added this to the script.

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

public class SlimeAi : MonoBehaviour 
{
	public GameObject slimeInfo;
	public bool Click = false;
	public GameObject Player;
	public bool Agro = false;
	public int pick = 1;
	public AnimationClip sMove;
	public int ran;
	public float move;
	void Start () 
	{
		slimeInfo = GameObject.Find("TextInfo");
		Player = GameObject.Find("Char");
		Invoke("Move", 1);
	}
	void Update () 
	{
		if(Click == false)
		{
			InfoOff();
		}
	}
	void OnTriggerExit (Collider Other) 
	{
		if(Other.tag == "AgroZone")
			Agro = false;
		if(Other.tag == "InfoZone")
			Click = false;
	}
	void Move () 
	{
		if(Agro == true)
		{
			pick = Random.Range(1, 3);
		}
		if(Agro == false)
		{
			pick = 1;
		}
		if(pick == 1)
		{
			ran = Random.Range(0, 271);
			transform.Rotate(Vector3.up * ran);
			animation.Play("sMove");
			transform.Translate(Vector3.forward * 25f * Time.deltaTime);
			Invoke("Move", 1);
		}
		if(pick == 2)
		{
			transform.LookAt(Player.transform);
			animation.Play("sMove");
			rigidbody.AddForce(Vector3.up * 10000);
			transform.Translate(Vector3.forward * 75f * Time.deltaTime);
			Invoke("Move", 0.5f);
		}
	}
	void OnTriggerEnter (Collider Other) 
	{
		if(Other.tag == "AgroZone")
			Agro = true;
		if(Other.tag == "InfoZone")
			Click = true;
	}
	void OnMouseDown () 
	{
		if(Click == true)
		{
			InfoOn();
		}
	} 
	void InfoOn () 
	{
		Text Slime = slimeInfo.GetComponent<Text>();
		Debug.Log ("InfoSlime");
		Slime.text = ("The Slime   -   Class E                   The most common monster also very easy to defeat.                    Special Attack : Jumps and moves forward quickly.");
	}
	void InfoOff () 
	{
		Text Slime = slimeInfo.GetComponent<Text>();
		Slime.text = ("");
	}
}

But if you click on the slime it does nothing.

I have all of the names correct but I don’t know whats wrong.

If anybody knows whats wrong please help.

-Thanks

Try putting Debug.Logs as the first thing in OnTriggerEnter/Exit and Mousedown. That, along with looking at how the globals change in the Inspector, will help you see what’s happening (I don’t know – your code makes my head hurt.)