Help me please

It says that in 25, 28 unity expects a ; but the problem is that its there already, what do i do. please help (the specific line says ´´string message “”;´´)

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

public class TimeGame : MonoBehaviour
{
    float roundStartTime;
    int waitTime;

    // Start is called before the first frame update
    void Start()
    {
        print ("Press space when you think the selected time passed");
        SetNewRandomTime();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            float playerWaitTime = Time.time - roundStartTime;
            float error = Mathf.Abs(waitTime - playerWaitTime);

            string message "";
            if (error < 0.15f)
            {
                message = "Nice!";
            }

            print ("You waited for " + playerWaitTime + " seconds. That's " + error + " seconds off.");
            SetNewRandomTime();
        }
    }

    void SetNewRandomTime()
    {
        waitTime = Random.Range (5, 21);
        roundStartTime = Time.time;

        print (waitTime + " seconds.");
    }
}

Look closely at line 25 (where the error message is pointing). What’s wrong with it? What’s the difference between it and the other lines where you’re assigning some value to a variable?

(Here’s a hint: something is missing.)

1 Like

Hello

You forgot an = in line 25.

Christoph

OH MY GOD IM AN IDIOT LMAOOOOO

how did i manage to overlook the fact that i forgot an = in line 25

1 Like

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.

When in doubt, call your dog over and explain each step of what you are trying to do. See my avatar picture.

the dog in your avatar pic looks adorable

1 Like