Access another object's variable

I’m trying to access a specific variable in a script attached to another gameobject.
I have no idea how to do this. Does anyone else know?
using UnityEngine;
using System.Collections;

public class StandardAttacksP1 : MonoBehaviour {

	public GameObject controllerDetect;
	public Component controllers;

	void Start () {
		controllers = controllerDetect.GetComponentInChildren<ControllerAmountDet> ();
	}

	void Update () {
		if (controllers.playerOneKeyboard == true) {
			//Do something
		}
	}
}

GameObject.Find(“objectname”).GetComponent().varibalename = 2;

make sure that variable are public