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

Question HELP NEEDED error CS0106: The modifier 'public' is not valid for this item

Discussion in 'Scripting' started by banga10, Apr 28, 2022.

  1. banga10

    banga10

    Joined:
    Feb 13, 2021
    Posts:
    5
    i find where it is wrong so i need some help:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class NewBehaviourScript : MonoBehaviour
    {
    public static bool gamestarter;
    public void gamestart;
    public GameObject mainmeu;
    private void Awake(){
    gamestarter = true;
    }
    // Start is called before the first frame update
    void Start()
    {
    Time.timeScale = 1.0f;

    }

    // Update is called once per frame
    void Update()
    {
    if(gamestarter){
    mainmeu.SetActive(true);

    if (Time.timeScale == 1.0f){
    Time.timeScale = 0.00001f;
    }
    if (Time.timeScale == 0.00001f){
    Time.timeScale = 1.0f;
    }

    }
    public void Startgame(){
    mainmeu.SetActive(false);
    }

    }
    }
     
  2. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
  3. banga10

    banga10

    Joined:
    Feb 13, 2021
    Posts:
    5
    thanks for the help
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,970
    For future reference, you can learn to fix all your own typographic errors this way:

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.