Hi there,
Just because i went crazy on this problem (for another reason than those posted here), I wanted to share in case another newbie had the same situation :
If you’re like me you, like to organize the Hierarchy and add plenty of objects into “folders” (which are technically empty gameObjects) to try some stuff.
In this case I named folder “Score” with other objetcs in it, including the actual Text “Score” we needed to use, resulting in the NullReferenceError.
The getComponent then loads the empty gameObject “Score” instead of your actual text “Score”…
Make sure the empty gameObjects are not named the same way as important objects !
Hope this will help if needed !
Cheers,
Q.