title: unity Subtraction Issue - Beginner
body: <p>I have a really basic problem.</p>
  <p>I want to display the score on my TextBox and add +1 when the &quot;OK&quot; button is clicked and subtract -5 when the &quot;NO&quot; button is clicked.</p>
  <p>But now I have the problem that it seems to me that the subtraction doesn't really work. Only one instance is displayed on the TextBox, i.e. if I click OK 10x in a row, I have 10 Points. If I now click on NO, the text field immediately shows -5, but it should be subtracted. If I click OK again, then I'll have 11 points, which shouldn't be the case, it should be 6.</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  
  public class Clicked : MonoBehaviour
  {
      public GameObject NO;
      public GameObject OK;
      public Text Points;
      public int score;
     
      public void OnClick()
      {
          Score(1);
          OK.transform.position = new Vector2(Random.Range(90, Camera.main.pixelWidth - 90), Random.Range(90, Camera.main.pixelHeight - 90));
          double rnd = Random.Range(0, 11);
          if (rnd == 1)
          {
              NO.transform.position = new Vector2(Random.Range(90, Camera.main.pixelWidth - 90), Random.Range(90, Camera.main.pixelHeight - 90));
              NO.SetActive(true);
  
          }
          else
          {
              NO.SetActive(false);
          }
      }
      public void Score(int points)
      {
          if(points == 5)
          {
              score = score - 5;
              Points.text = &quot;Punkte : &quot;+score;
          }
          else if(points == 1)
          {
              score++;
              Points.text = &quot;Punkte : &quot;+score;
          }
         
      }
      public void OnClickNo()
      {
          Score(5);
          NO.SetActive(false);
  
      }
  
      void Start()
      {
          NO.SetActive(false);
        
          Points.text = &quot;Punkte : &quot; + score;
      }
  
  }
  </code></pre>
  <p><strong>EDIT</strong>
  I changed now everything, removed the connection to all controls, add only one to it and add a Listener at start method.
  It seems now to work.
  Thanks :)</p>
  <pre><code>public class Clicked : MonoBehaviour
  {
      public Text Points;
      public int score = 0;
  
  
      [SerializeField]
      private Button OK;
  
      [SerializeField]
      private Button NO;
  
  
      public Button SelectedButton
      {
          get; private set;
      }
  
      private void Start()
      {
          Points.text = &quot;Punkte : &quot; + score;
          NO.onClick.AddListener(() =&gt; SelectButton(NO));
          OK.onClick.AddListener(() =&gt; SelectButton(OK));
      }
  
      public void SelectButton(Button button)
      {
          SelectedButton = button;
          if(button == OK)
          {
              score++;
              Points.text = &quot;Punkte : &quot; + score;
              OK.enabled = (SelectedButton == OK);
              OK.transform.position = new Vector2(Random.Range(90, Camera.main.pixelWidth - 90), Random.Range(90, Camera.main.pixelHeight - 90));
              double rnd = Random.Range(0, 5);
              if (rnd == 1)
              {
                  NO.transform.position = new Vector2(Random.Range(90, Camera.main.pixelWidth - 90), Random.Range(90, Camera.main.pixelHeight - 90));
  
              }
          }
          else if(button == NO)
          {
              score -= 5;
              Points.text = &quot;Punkte : &quot; + score;
              NO.enabled = (SelectedButton == NO);
              NO.transform.position = new Vector2(Random.Range(90, Camera.main.pixelWidth - 90), Random.Range(90, Camera.main.pixelHeight - 90));
  
          }
  
  
      }
  }
  </code></pre>