- Home /
 
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               Abhi94 · Jun 21, 2015 at 10:55 AM · 
                scripting problemscoreadd  
              
 
              My score script doesn't seem to work properly, score is not added properly
My score should increase by 10 with each right answer ,but it seems to remain static at 10 so please help me with with -
 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class onClick1 : MonoBehaviour {
 
     public Text ScoreText;
     public int score;
     private int Count = 10;
 
     public bool hello;
     private float RightAnswer = 2.0f;
 
     void Start () 
     {
 
         score = 0;
         UpdateScore ();
 
         }
 
 
     public    void SayHello(  bool hello = false ) {
 
 
         
       if (GetComponent<Image> ().color == GameObject.FindGameObjectWithTag ("DisplayButton").GetComponent<Image> ().color) {
 
             GameObject thePlayer = GameObject.FindGameObjectWithTag("GameController");
             DisplayColor displayColor = thePlayer.GetComponentInChildren <DisplayColor>();
         
             ChangeColor[] changeColors = thePlayer.GetComponentsInChildren <ChangeColor>();
             
             foreach(ChangeColor changeColor in changeColors ) {
                 Debug.Log(changeColor .gameObject.name);
                 changeColor.ColorME();
             }    
 
 
             Timer timer = thePlayer.GetComponentInChildren<Timer>();
 
             
             hello = true;
             displayColor.changeColor();
             timer.myTime += RightAnswer;
 
             **AddScore();
             UpdateScore();**    
         
         
         } else if (GetComponent<Image> ().color != GameObject.FindGameObjectWithTag ("DisplayButton").GetComponent<Image> ().color) {
     
             hello = false;
 
         
 }
     
 
     
     }
 
 
     **public    void UpdateScore() {
         
         ScoreText.text = "Score: " + score;
         
     }
     
     public void AddScore( )
     {
         
         score += Count;
         UpdateScore ();
         
     }**
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
INCREASE SCORE MORE AND MORE? 1 Answer
Ending a game with Points 1 Answer
Problem at add Score+1 When Pass rocks 0 Answers
Scoring points problem 1 Answer
Can't increase my score after OnTriggerEnter occurs. 1 Answer