I want to when i will press “Buy Dealer” button,function Deal will loop.Every 3 seconds Deal function need to add +20$ and -1g meth…
…So,when i apply this script unity is crashing…How to loop a function,please help and sorry for my broken english.
function Update()
{
if(dealers >=1)
{
if(methScript.meth >=1)
{
while(true)
{
Deal();
}
}
}
}
IEnumerator time()
{
yield return new WaitForSeconds(3f);
}
void Deal()
{
moneyScript.money +=20;
methScript.meth -=1;
StartCoroutine(time());
}