If statements based on conditionals in another script

I’ve tried other forums that attempt to deal with this problem but none worked for me.

How do I write if statements where the attributes being compared are declared and manipulated in a different script? I’m very new to programming so I’m pretty clueless.

In my specific example case, I’m trying to program a betting board. The player chooses a chip by clicking it’s icon, this should turn a boolean attribute I named “redclicked” to true, to signify it’s been selected. When the player clicks the tile they want to place the chip on, a different script checks whether redclicked = true before enabling the chips icon to appear on that specific tile.

the if statement doesn’t work because the attribute being compared, “redclicked” is in a different script so I was wondering what solutions there are for this.
172951-image-2020-12-22-182926.png

You don’t have access to the Boolean, redclicked because you need a reference to the other script. You can do this like so:

public class ImageClick : MonoBehaviour
{
    [SerializeField] private ChipChooser chipChooser;
    public Image image;

    private void Start()
    {
        if( chipChooser == null )
            chipChooser = FindObjectOfType<ChipChooser>();
    }
    public void OnMouseDown()
    {
        if( chipChooser.redclicked )
            image.enabled = !image.enabled;
    }
}