Help with corutine

I always have problem with this function.
Anyway i am trying to load a level when you click on button.
So heres my code

  public void loadlevel(string lvlname)
    {
        StartCoroutine (displayloadingscreen (string lvlname));
    }
    IEnumerator displayloadingscreen(string lvlname)
    {
        AsyncOperation async = Application.LoadLevelAsync (lvlname);

        while (!async.isDone) {
            bar.GetComponent<loadingbar> ().progress=async.progress;

            yield return null;
        }
   }

I am getting Unexpected symbol ‘lvlname’, expecting’.’ error

StartCoroutine(displayloadingscreen (string lvlname));

Should be

StartCoroutine(displayloadingscreen (lvlname));
1 Like

DanielQuick is absolutely right!

You’ve already declared the string “lvlname” when you setup up the declaration for the funtion…

 public void loadlevel(string lvlname)

… so there is NO need to declare it again when you start the coroutine.