My code is not working

Hi,
On this lesson my code stopped working for me. Before that whenever i pressed buttons things worked, now all i got is an welcome text . I’ve looked into cheat sheets and couldn’t locate my eror. Here is my code.
Please help

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

public class NumberWizzard : MonoBehaviour
{
    int max;
    int min;
    int guess;

    // Start is called before the first frame update
    void Start()
    {
        StartGame();
    }


    void StartGame()
    {
        max = 1000;
        min = 1;
        guess = 500;

        Debug.Log("Shalom Ahi!!Bruhim abaim to Number Wizzard ");
        Debug.Log("Pick a nmber haim sheli, don't tell me what it is....");
        Debug.Log("The highest number you can pick is " + max);
        Debug.Log("The lowest number you can pick is " + min);
        Debug.Log("Kapara,tell me if your number is higher or lower than:" + guess);
        Debug.Log("Push up = higher, Push Down = Lower, Press Enter = Correct");
        max = max + 1;
    }

    
   
    
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
           
            min = guess;
            NextGuess();
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            max = guess;
            NextGuess();
        }
       else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("I am a genius");
            StartGame();
        }
    }
    void NextGuess()
    {

        guess = (max + min) / 2;
        Debug.Log("Is it higher or lower than..." + guess);


    }
}

thank you!

Hi,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? If so, does MonoBehaviour have the same colour as your classname in your script? If not, there might be a problem with Visual Studio. Please watch lecture “Fixing Visual Studio Problems” (currently #4).

Have you tried to restart Unity and Visual Studio?

And did you press the Play button?

This topic was automatically closed after 27 hours. New replies are no longer allowed.

Privacy & Terms