bool not properly working and time counter only adding once

Hey, I’m trying to have a counter after chopping down a tree, so I can spawn it again after a couple of seconds, but the problem is that the IF test is not reacting even though the bool is set to true…

using UnityEngine;
using System.Collections;

public class mineTreeStaticMap : MonoBehaviour {
	
	GameObject manager;
	GameMangerINV managerScript;
	public int treeHealth = 100;
	public int currentTreeHealth;
	public float time = 0;
	public float timeToSpawn = 10;
	public bool treeDead = false;
	void Start () {
		manager = GameObject.Find("Player"); //GearMaster
		managerScript = manager.GetComponent<GameMangerINV>();
		currentTreeHealth = treeHealth;
		treeDead = false;
	}
	
	
	void Update () {
		if (currentTreeHealth <= 0) {
			gameObject.SetActive(false);
			treeDead = true;
		}
		if(treeDead == true){
			time = time + Time.deltaTime;
			Debug.Log ("TIMER:" + time);
			if(time >= timeToSpawn) {
				gameObject.SetActive(true);
				currentTreeHealth = treeHealth;
				time = 0f;
			}
		}
		
	}
	
	public void getDamage(int dmg) {
		print ("fant");
		currentTreeHealth = currentTreeHealth - dmg;
		//healthslider.value = treeHealth;
	}
}

Also if you have any recommendations, I would gladly take them. I’m worried about the game lagging when it counts in every frame.

Thanks.

@timzand

This should do it for you

using UnityEngine;
using System.Collections;

public class mineTreeStaticMap : MonoBehaviour
{
    GameObject manager;
    GameMangerINV managerScript;
    public int treeHealth = 100;
    public int currentTreeHealth;
    public float time = 0;
    public float timeToSpawn = 10;
    public bool treeDead = false;

    void Start ()
    {
        manager = GameObject.Find("Player"); //GearMaster
        managerScript = manager.GetComponent<GameMangerINV>();
        currentTreeHealth = treeHealth;
    }


    void Update ()
    {
        if ((currentTreeHealth <= 0) && (!treeDead))
        {
            gameObject.SetActive(false);
            treeDead = true;
            StartCoroutine(StartTimer());
        }
    }

    IEnumerator StartTimer()
    {
        yield return new WaitForSeconds(timeToSpawn); 
        currentTreeHealth = treeHealth;
        treeDead = false;
        gameObject.SetActive(true);
    }

    public void getDamage(int dmg)
    {
        print ("fant");
        currentTreeHealth = currentTreeHealth - dmg;
        //healthslider.value = treeHealth;
    }
}