access float from gameobject hit with raycast

There are several instances of the gameobject “Mover” in the scene.
When the “follower” game actor is over the “mover”, the mover should tell the “follower” which direction and speed to go.

I’ve tried as many different ways i could find of using GetComponent, but i am now getting a null reference exception, “Object reference not set to an instance of an object”. It sounds pretty self explanatory but I haven’t been able to find anything on it.

I need to get the variables for speed and angle from the Mover object detected with my raycasthit.

void Update () {
		RaycastHit hit = new RaycastHit ();
		// Let's see if there is something below us.
		if (Physics.Raycast(transform.position, Vector3.forward, out hit , castRange)) {
			Debug.Log ("I am on something...");
			Debug.Log (hit.collider.gameObject.tag);
			// Is something below us tagged as a Mover?
			if (hit.collider.gameObject.tag == "Mover") {
				Debug.Log ("Oh, I am on a Mover!");
				moving = true;
			}
			// If I am on a mover, i want to move the direction and speed values given by that mover
			if (moving = true) {
				
				moveDirection = GetComponent<moverAttributes>().moverDirection; //(hit.collider.gameObject);
				print (moveDirection);

Update:

Right now the current iteration of the code is at:

using UnityEngine;
    using System.Collections;
    
    public class followerAttributes : MonoBehaviour {
    	
    	bool moving = false;
    	float oldMoveSpeed = 3.0f; //planning to remove
    	Vector3 East = Vector3.left; //planning to remove
    	float moveSpeed;
    	float castRange = 1000;
    	float moveDirection;
    	//Quaternion rotation = Quaternion.identity;
    
    	// Use this for initialization
    	void Start () {
    
    		
    	}
    	
    	// Update is called once per frame
    	void Update () {
    		RaycastHit hit = new RaycastHit ();
    		// Let's see if there is something below us.
    		if (Physics.Raycast(transform.position, Vector3.forward, out hit , castRange)) {
    			Debug.Log ("I am on something...");
    			Debug.Log (hit.collider.gameObject.tag);
    			// Is something below us tagged as a Mover?
    				moving = hit.collider.CompareTag("Mover");
    			// If I am on a mover, i want to move the direction and speed values given by that mover
    			if (moving) {
    				
    				Debug.Log ("Oh, I am on a Mover!");

				//This is the line giving me a null reference exception error
				moveDirection = hit.collider.GetComponent<moverAttributes>().moverDirection;//(hit.collider.gameObject);
				print (moveDirection);

    				float angleTest = moveDirection;
    				float xMove = Mathf.Sin (Mathf.Deg2Rad * angleTest);
    				float yMove = Mathf.Cos (Mathf.Deg2Rad * angleTest);
    				
    				Vector3 thatWay = new Vector3 (yMove, xMove, 0);
    				transform.Translate (thatWay * oldMoveSpeed * Time.deltaTime);
    				print (xMove);
    				print (yMove);
    			}
    		}
    	}
 }

I truncated all the stuff commented out…
The demo i have working is here: http://soylentworks.com/codesucks/Builds/TouchnDrag.html
I need the sphere’s to follow the angle of the belts. I am a total noob to coding, so i am probably overlooking something basic.

There are two problems:

1- if (moving = true) is wrong - it should be if (moving == true) or just if (moving). This error is assigning true to moving and also making the if code be always executed, what originates the null exception when the detected object doesn’t have the script moverAttributes. Read the 11th commandment below.

2- GetComponent alone searches for the component in this object only! You should prefix it with a reference to the target object - which’s easy to get from hit :

     ...
     // If I am on a mover, i want to move the direction and speed values given by that mover
     if (moving == true) { // <== read item 1 above
       // prefix GetComponent with the object reference, as said in item 2:
       moveDirection = hit.transform.GetComponent<moverAttributes>().moverDirection; 
       print (moveDirection);
       ...

Actually, boolean variables should never be compared to true or false - they are intended to be tested directly, like this:

if (moving){ // is moving true?

if (!moving){ // is moving false?

11th: Commandment: God created the booleans to be tested directly, and the sinners who compare them to true or false will be punished with logic errors for the eternity!