Accessing variable from another script

Hi

I have a script(dashboard) and has a variable named Speed, and i want to access that from this script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RPM_Color : MonoBehaviour {

	private Dashboard x;

	void Start () {
		Dashboard x = GetComponent<Dashboard> ();
	}
	
	void Update () {
		Debug.Log (x.speed);
	}
}

the console says:

NullReferenceException: Object reference not set to an instance of an object
RPM_Color.Update () (at Assets/_Scripts/RPM_Color.cs:17)

how can i fix this?

I know that so many of this kind of questions has been asked by people , but i dont understand even single one of them ! i’m new to C# please be clear and simply explain what is going on here with damn c#

THANX BY THE WAY !

Start happens on the 1st frame, and Update happens on every frames.
So, if I’m not mistaken, you should assign x in Awake instead. Also, you want to assign to the already declared member, so without providing the type again.

[RequireComponent (typeOf (Dashboard))] // enforces there's a Dashboard component on the same object
public class RPM_Color : MonoBehaviour
{
    private Dashboard x;
    
    void Awake ()
    {
       x = GetComponent<Dashboard> (); // assign to already declared member
    }
    
    void Update ()
    {
        Debug.Log (x.speed);
    }
}

public Dashboard d; //Assign this in the inspeactor
private float xpeed;

void Update(){
xspeed = d.speed;
} 

Debug.Log(xspeed);

And! very important!! The var speed must be public!!