Read variable form another Class?

Okay, I know this is something there is a lot of online but i can’t seem to get my script to work. I have a class in which I try to get a boolean I can set in it from,
And then in my other class (that is supposed to read that boolean) I want to be able to set left and right direction.
So the boolean is IsLeft, I put it on two gameObjects with the same name so that when I click on them is IsLeft = true, then my GameObject will move left.

Any ideas as to what I should do?

// Attach the object with the script in the Inspector
public GameObject objectWithScript;
// This is the class that you defined in the script
MyClass myClass;

void Start()
{
    myClass = objectWithScript.GetComponent<MyClass>();
}

void Update()
{
    myClass.someVar += 1;
}