You should use code tags for your code.
var like = this;
It would make your snippet much more readable and I wouldn’t have to count the rows to get to the error on line 26 …
All in all, you messed big time, it’s clear as day you don’t really know what you’re doing.
So let’s start from the beginning.
-
Your class is called ‘Connector’. It connects what exactly? This is just a question, not a problem in itself. You can probably choose a better name for this script.
-
You declare two field variables
enemyScore
andcollectionScore
and these are of typeText
, so I’m guessing it’s the visible part of your GUI with which you actually present the score values. -
However, there are no values themselves.
-
In Update, you suddenly declare another local variable with the same name of
enemyScore
, and this has consequences. Namely, it hides the already existing class field because it has the same name. And then you assign to this variable some value that you fetch from a component on another object, viaGameManager
singleton. I can’t tell if this is correct. -
Now
enemyScore.text
probably can’t work, because the local variableenemyScore
is of typeint
and has notext
property. -
For a similar reason,
collectionScore.ToString()
probably doesn’t return anything meaningful, becausecollectionScore
is a class field which is of typeText
, so it probably only returns the word “Text”.
Pretty bad all around
1/10
But we’re here to help. However, there is not much else I can help you with.
If you don’t understand your errors, all I can say is that you need to achieve a better command over programming.
Really the basics; what is left and what is right. How variables work, how scopes work, the classes, the objects, fundamentals of OOP, as well as the nominal C# syntax … If you knew that, you would understand exactly what your instructor did and why it worked.
Feel free to ask something specific if that helps you get a better grasp on this problem.