life is null

can you give me a code. i have 3 lives but when i click wrong button continuously it shows that life turns to negative ( example. -1, -2…) can you please help me on my code?

void OnClickWrong(){
life -= (life > 0) : 1:0;
}

It’s just a pseudo code.

Here is what I think you want

If you want to display some kind of Game Over screen when lives = 0 it is this simple,
change this at the beginning of the script.

using UnityEngine;
using System.Collections;

to this

using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;

then do this.

 void OnClickWrong(){
       life -= 1;
 }
void Update () {
       if (life == 0)
       SceneManager.LoadScene (sceneindex); //replace scene index with the game over scene's index


}

however, if you don’t want there to be a game over, there is a way to simply keep it from going below 0, by clamping it. Add this to OnClickWrong.

  void OnClickWrong(){
        life -= 1;
        life = Mathf.Clamp(life, 0f, Mathf.Infinity);
  }

That should just stop it from going below 0, if neither of these are what you wanted, just comment and I will do my best to answer. All code is untested, but should work.