How do I change a variable in one script from a second script?

How do I change a variable in one script from a second script?

I have a script named ScriptOne attached to one object, and it has the following variable

var work : boolean = false

To change that variable from a script named ScriptTwo attached to another object, I thought I would just need to type into ScriptOne

GetComponent (ScriptOne.work) = true; 

This doesn't seem to work, so what is the actual format?

GetComponent(ScriptOne).work = true;

Although, since your script is on another object, it's a bit more work

You'll need to get the gamebject by tag or name (unless you have an inspector assigned link to it)

Something like this:

var go = GameObject.Find("YourObjectsName");
go.GetComponent(ScriptOne).work = true;

Or this:

var go = GameObject.FindWithTag("YourObjectsTag");
go.GetComponent(ScriptOne).work = true;