error CS0135: `instance' conflicts with a declaration

I have a gameobject that’s supposed to be instantiated and destroyed quickly. Problem is, Instead of being instantiated once, my gameobject is being instantiated multiple times. So I decided to limit it with a boolean. Problem is that I get an error… see for yourself:

using UnityEngine;
using System.Collections;

public class ActivateEffect : MonoBehaviour {
    public GameObject LightningPrefab;
    public GameObject instance;
    private bool InstantiateOnce;

    // Use this for initialization
    void Start () {
        InstantiateOnce = false;
    }

    void FixedUpdate ()
    {
        if (Input.GetKeyDown(KeyCode.L) && InstantiateOnce == false) {
            var instance = (GameObject)Instantiate (LightningPrefab, transform.position, LightningPrefab.transform.rotation);
            InstantiateOnce = true;
            Destroy (instance, 0.5f);
                }
        if (instance == null)
        {
            InstantiateOnce = false;
        }
    }

}

Assets/CustomModels/ActivateEffect.cs(21,21): error CS0135: `instance’ conflicts with a declaration in a child block

You declare “instance” inside the block that is lines 16-20. However, you’re checking its value outside that block, on line 21.

If you nest that null check inside your first block, it should work.

Thanks, I thought I already did that from some reason.

You can’t declare the same variable twice. You declare instance at the top if your script. You declare instance again in the body.

Simply remove car from line 17 to fix.