Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question error cs 1002

Discussion in 'Code Editors & IDEs' started by matveyagapov, May 26, 2022.

  1. matveyagapov

    matveyagapov

    Joined:
    May 20, 2022
    Posts:
    4
    Code (CSharp):
    1.  
    im making a game and i need a gui that shows how much game currency do you have ive made this code
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using unityengine.gui;
    6.  
    7. public class moneyscript : MonoBehaviour
    8. {
    9.  
    10.     public float money = 0f;
    11.     public text textmeshpro moneytext;
    12.  
    13.         // Use this for initialization
    14.     void Start()
    15.     {
    16.  
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update()
    21.     {
    22.  
    23.     }
    24. }
    25.  
    and got the error: Assets\moneyscript.cs(10,29): error CS1002: ; expected
    pls help
     
    Last edited: May 27, 2022
  2. naknuknik

    naknuknik

    Joined:
    Mar 14, 2021
    Posts:
    19
    I think you should be getting other errors(namespace on line 5,declaration on line 11), but regardless I recommend learning the C# syntax a bit. Maybe watch a few tutorials/check out msdn( https://docs.microsoft.com/en-us/dotnet/csharp/ ).Or if you can afford it, I recommend just picking up an introductory book as those are wildly helpful with introducing many concepts that youll probably need.
    Edit: fix link
     
    Last edited: May 28, 2022
  3. matveyagapov

    matveyagapov

    Joined:
    May 20, 2022
    Posts:
    4
    thank you very much
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,463
    This is a great example of why you shouldn't pay too much attention to the error message because the error here is wrong. You're not missing a semicolon. Line 5 has improper capitalization. Line 11 has improper capitalization and you're trying to assign two types to a variable.