the function launched from OnClick does not work as it should

I have such a function

public void SetChoice(int x)
    {
        Debug.Log(x + equiped[x].ToString());
        if (equiped[x])
        {
            choice = x;
            Debug.Log("ustawiło się");
        }
        else Debug.Log("nie masz itemu");
    }

which is assigned to buttons in OnClick, the problem is that it works as if every element in the equiped array was false, but this is not the case when writing DebugLog in the Update tells me true every time, which is how it should be, only in this function, it doesn’t work, and when I run this function in the Update, it works fine, so the problem probably results from the fact that it is triggered by a button

and I also discovered that if I change the variable in this function, Update does not see it either

I fixed it