How do I deduct points for incorrect inputs?

Basically my game is like dance dance revolution where a random arrow from the 4 arrows light up and the user must enter the corresponding direction, either by WASD or arrow keys. But I want to add a scenario where the game deducts points when the user enter the wrong input. Below is a sample of what I wrote for the up arrow showing up.

if (RandomID == 0)
            {
                sprites[RandomID].GetComponent<SpriteRenderer>().color = new Color(1, 0.61f, 0, 1);
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    score = score + 10;
                    //Debug.Log(score);
                    //scoreBoard = score.ToString("0");
                    sprites[RandomID].GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
                    RandomID =  Random.Range(0, sprites.Length);
                    Debug.Log(RandomID);
                    yield return new WaitForSeconds(sleepTime);
                    
                }
                else if (Input.GetKeyDown(KeyCode.W))
                {
                    score = score + 10;
                    //Debug.Log(score);
                    //scoreBoard = score.ToString("0");
                    sprites[RandomID].GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
                    RandomID =  Random.Range(0, sprites.Length);
                    Debug.Log(RandomID);
                    yield return new WaitForSeconds(sleepTime);
                }else
                {
                    score = score - 10;
                }
            
            }
}

Hi @superchrist345, please explain what your current code does. I suggest you edit your above post and put the explanation there.

Typically you need to identify which one is highlighted using a string or an integer. Each input has a corresponding value. You then need to associate the object your highlighting with the identifier.

For example, you have an array of the sprites to highlight: Sprite sprites where up at index 0, down is index 1, and so on. In pseudo code:

sprites[0] = upSpriteReference;  
sprites[1] =  downSpriteReference;
         then get a random integer from all possible array indexes to highlight.
randomIndex = Random.Random( 0, sprites.length )
        and highlight the sprite
sprite[randomIndex].GetComponent<SpriteRenderer>().color = new Color(1, 0.61f, 0, 1);
        then your input code needs, for example
if( input w key ) 
     if randomIndex == 0 then add to score
     else subtract from score
else if( input s key )
      if randomIndex == 1 then add to score
     else subtract from score
 and so on for your other keys

It looks like your code is kind of doing that, but it’s not clear (and it looks like your forcing your RandomID to always be zero… )