How to use member variable of c sharp script in another c sharp script?

I have a script called tankMovement.cs in which I have ‘public bool b_TankIsMoving = false;’
In a second script called audioTankEngine.cs I try to use that bool like this:
‘if (tankMovement.b_TankIsMoving == true) {//do some code that starts tank engine sounds}’

This is the compile error I get. Apparently I need to create some kind of reference? “Error CS0120: An object reference is required for the non-static field, method, or property ‘tankMovement.b_TankIsMoving’ (CS0120) (Assembly-CSharp)”

In your first script tankMovement.cs change the line of ‘public bool b_TankIsMoving = false’ to ‘public static bool b_TankIsMoving = false’.

To access a non-static member, you need a reference to the object.

public class A : MonoBehaviour
{
    public bool foo;
}

public class B : MonoBehaviour
{
    public A a;

    void Start()
    {
        print(a.foo);
    }
}

When B starts, if a has been set up in the inspector, it will print whatever value a.foo was set to.

If you don’t want to set up references in the inspector, you must obtain a reference to the object.
If the component sits on the same game object, you can get the reference with GetComponent() like so:

    void Start()
    {
        a = GetComponent<A>(); // Get A from same game object as me!
        print(a.foo);
    }

If the component sits on another game object, use GameObject.Find for example to obtain a GameObject.

    void Start()
    {
        // Requires an active game object called "A Provider" to exist in the scene.
        GameObject remote = GameObject.Find("A Provider"); 
        a = remote.GetComponent<A>(); // Get A from the remote object
        print(a.foo);
    }