Error CS0127
Here is my code: using UnityEngine; using System.Collections;
 public class Difficulty : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         GameObject thePlayer = GameObject.Find("_scorer");
         score score = thePlayer.GetComponent<score>();
         GameObject spawnerobject = GameObject.Find("spawn 1");
         spawner spawner = spawnerobject.GetComponent<spawner>();
         if (score.theScore >= 100) {
             spawner.Difficulty2 ();
         }
         return Update();
     }
 }
and for the other script:
 using UnityEngine;
 using System.Collections;
 
 public class spawner : MonoBehaviour {
 
     public int Wait_time;
     public Transform CUBE;
 
     // Use this for initialization
     void Start () {
         Wait_time = Random.Range (1, 5);
         StartCoroutine (waiter ());
 
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     IEnumerator waiter()
     {
         yield return new WaitForSeconds (Wait_time);
         spawn();
     }
 
     void spawn()
     {
         Transform temp = Instantiate(CUBE, transform.position,Quaternion.identity) as Transform;
         StartCoroutine (waiter ());
     }
     public void Difficulty2 ()
     {
         StartCoroutine (Difficultyset ());
     }
     IEnumerator Difficultyset()
     {
         Wait_time = Random.Range (1, 4);
         spawn ();
     }
 }
 
I get this for some reason:
Assets/Difficulty.cs(20,17): error CS0127: Difficulty.Update()': A return keyword must not be followed by any expression when method returns void i have tried taking off the return but then i get this error: Assets/spawner.cs(36,21): error CS0161: spawner.Difficultyset()': not all code paths return a value
I dont have any clue of whats going wrong can someone come up with a solution to this problem.
Scott.
Answer by doublemax · Oct 16, 2016 at 12:28 PM
 return Update();
This must be removed completely.
The second error is a different issue. The method "Difficultyset" contains no yield of any kind and therefore can't be started as a Coroutine(). The way the method is now you could just call it like a normal method. Alternatively add a "yield break;" at the end of the method.
Your answer
 
 
             Follow this Question
Related Questions
0xc000007b error on 64 bit machine? 1 Answer
Position is infinite 0 Answers
Unity Package Manager Error 4 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                