Hello people!
Today i’ve been sitting around reading into javascript tutorials but im still clueless on how i can make the tree drop more instances of ‘wood’ the longer it grows, like here’s the section of my tree script. Like basically what im trying to achieve is for the tree to drop more of the object the more seconds its there. If that makes sense in the slightest? 
var wood : Transform; //name of object
var amountOfClicks:int=0;
function OnMouseDown(){
if(amountOfClicks>2){
Destroy(gameObject);
Instantiate(wood, transform.position, Quaternion.identity);
}
else{
amountOfClicks++;
}
}
Thanks for any information 
You can save a time stamp when the object is created and get the time passed in your OnMouseDown event. You can then simply divide the time (seconds) passed by a factor, to get the amount of chunks.
This is C# code, but it should easily translate to js.
// ChunksOverTime.cs
using UnityEngine;
public class ChunksOverTime : MonoBehaviour
{
public int spawnRate = 10; // how many seconds it takes to "generate" a new chunk
private float spawnTime; // time the tree was created
void Start()
{
spawnTime = Time.time;
}
private int GetChunks()
{
return Mathf.CeilToInt((Time.time - spawnTime) / spawnRate); // the amount of chunks, rounded up so there will be at least 1
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Time: " + (Time.time - spawnTime).ToString("F2") + " Chunks: " + GetChunks());
}
}
}
Thank you for this! I’ll test it out when I get home 