Buttons changes score

I have four buttons.

    public Text score;
	public int totalscore = 0;

	public void OnButtonClick(int num) {
        //num will tell us which button was pressed 
        totalscore.text = score++;  
}

Score becomes 1, 2 and again 1 then 3
It because every button holds separate score.

How do i share the score variable among the four buttons?

Use the static keyword.

public static int totalscore = 0;