This is simple: you never initialize
gameOverScore
in your code. When you try get calculate the property
gameOverScore.guiText
, you try to dereference object by calling its property
guiText
, and it throws the exception because, at this moment, the reference
gameOverScore
does not point to any
GUIText
object. Initialization could be something like
gameOverScore = new GUIText( );
[EDIT]
Your conceptual mistake is
thinking that you are doing assignment by this code
gameOverScore.guiText = someValue;
Instead, you assign the value to the property "guiTest", which is equivalent to access to the element of associative container by string index:
gameOverScore["guiText"] = someValue;
Note that understanding of properties as elements of associative containers is in a deep nature of Javascript, one of the most fundamental ideas of this language.
—SA