IEnumerator Chop(GameObject veg, movement player) { salad.InChoping(); //ProgressBar.transform.localScale = Vector3.one; player.AllowMove = false; float t = veg.GetComponent <Vegetable>().ChoppingTime; //float factor = Time.deltaTime / t; Vector3 scalefactor = new Vector3(Time.deltaTime / t, 0, 0); while (t > 0) { t -= Time.deltaTime; if (ProgressBar.gameObject.transform.localScale.x > 0) { ProgressBar.transform.localScale -= scalefactor; } else { ProgressBar.transform.localScale = Vector3.zero; } yield return(null); } player.AllowMove = true; salad.EndOfChopping(); yield return(new WaitForSeconds(1)); ProgressBar.transform.localScale = Vector3.one; }