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. Dismiss Notice

Question NullReferenceException: Object reference not set to an instance of an object ChoiceScript.Yes()

Discussion in 'Scripting' started by Wizkid215, Jun 21, 2023.

  1. Wizkid215

    Wizkid215

    Joined:
    Apr 15, 2016
    Posts:
    2
    I'm trying to make a multiple choice script but its telling me that these two lines are null. So whenever I click my buttons the text doesn't change when it is supposed to when the buttons are clicked. I'm not sure why it is null, please help. test.PNG
     
  2. DavidTeo

    DavidTeo

    Unity Technologies

    Joined:
    Apr 1, 2021
    Posts:
    69
    Firstly, welcome to Unity Forums!
    I noticed that the question isn't really meant for this 2D section, you will have better luck if its posted in the appropriate section on either the Scripting or the UI section.

    One of the hints the error message is trying to communicate to you is that your objects aren't referenced correctly, you might want to check the script if you have correctly set that textbox gameobject correctly in the Inspector
     
  3. Wizkid215

    Wizkid215

    Joined:
    Apr 15, 2016
    Posts:
    2


    Ok thanks I can repost it in the other sections if I can't figure it out yet. I can check out the Inspector to see what's up too but it looks like the right gameobject that's connected to the script if thats what you mean. test.PNG
     
  4. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    ask @Kurt-Dekker he will teach u
     
    Kurt-Dekker likes this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762