Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

I need help with MainMenu

Discussion in 'Scripting' started by kehveli609, Mar 15, 2021.

  1. kehveli609

    kehveli609

    Joined:
    Jan 11, 2021
    Posts:
    2
    Can some1 maybe help me bc i cant move on in my game bc i have errors and i dont know almost nothing about scripting so i watched tutorial but i still got errors so here`s what i have

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.scenemanagement;
    5.  
    6. public class MainMenu : MonoBehaviour
    7.  
    8.     public void playgame ()
    9. {
    10.     sceneManager.loadscene(scenemanager.getactivescene().buildindex + 1);
    11. }
     
  2. kehveli609

    kehveli609

    Joined:
    Jan 11, 2021
    Posts:
    2
    PRoblemo.png

    I dont even know what those ERROR acculy means so im stuck
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    In the specific case above, you have at least half of your identifiers mis-capitalized.

    Capitalization, spelling and punctuation have to be 100% PERFECT for programs to work.

    I see mis-capitalization on line 4, line 10 (in five (5) separate places on that one line!), etc.

    Go look up the scene manager docs to see what I mean.

    And you're missing a closing brace on your class.

    Again, EVERYTHING has to be perfect, no room for errors, not even one character wrong.
     
  4. JoelLeeJie

    JoelLeeJie

    Joined:
    Jul 4, 2020
    Posts:
    20
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class MainMenu : MonoBehaviour
    7. {
    8.     public void playgame()
    9.     {
    10.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    11.     }
    12. }
    1. the class needs to have brackets, not just the function. E.g. public class MainMenu : MonoBehaviour { }

    2. Try using "Intellisense", it'll help alot:)

    Should be fine i think.
     
    kehveli609 likes this.