Help with referencing

Hi there,

I’m quite new to scripting and Unity, and I encountered something that I don’t quite get, but would really like to understand:


I have the “???” text ready to change depending on my script.
In my script, I’ve imported UnityEngine.UI and initialized a Text variable which I would change later on in the script.
Problem:
(I don’t know what technical terms to use here, so excuse me for my explanation)
When I add my script as a component to the text itself, and reference the text like so:

[guess being the “???” text]

I get this error:
3052055--229024--upload_2017-4-29_20-8-24.png
and the text doesn’t change since the first time it was set. The line is " currentGuess.text = guess.ToString();"

However when I do the same with an empty gameobject instead, it works like a charm.

If anyone who reads this understands what I’m trying to ask, could you explain why one works and the other one doesn’t?

Been a while since I ran through that Udemy course :stuck_out_tongue:

Are you draging the object from the hierachy?

Although, they do have dedicated forums for that course.

Depends on your variables, maybe. Hard to say without seeing the code.