I need a button that changes its image given the variables from another script (not the built-in spriteswap), how do I code it?

So, I have 3 images that are alternatives for the button, and I need the button to show one of them given the variables from another script. Now, the problem isn’t getting the variables from the other script, the problem is making the button show different images, how do I make a script like that?

@Marcos_Bravo

public class MySample : MonoBehaviour
{
    public Button myButton;

    public Sprite sprite1;
    public Sprite sprite2;

    public bool x; // Used only for the condition example

    private void Start()
    {
        if (x)
        {
            myButton.image.sprite = sprite1;
        }
        else
        {
            myButton.image.sprite = sprite2;
        }
    }
}