Public void GmAddScore() is not working properly

kindly help me ,I have done all, but this error prevent me to play my own game, anyone code master kindly help , GmAddScore is not working ,
Public Void GmAddScore(){
this.myScore++;
}
and i call it on the obstacles script but unity shows all of the errors abour the same it dont adding the score , and dragon drops down and error generating continously :frowning: :cry: please somebody help , its about my lots of struggle :frowning:

GameObject.Find() searches for a GameObject in the scene that has the name you specify. You can’t use it to find individual components like your GameManager script, you instead have to input the name of the GameObject that has the GameManager script attached to it.

It looks as though he’s using GetComponent in the call, too.

This was double posted. OP: Please don’t double post.
I responded to this in ‘Scripting’, I believe.

Edit: Correction, sorry… the post to which I responded was a reply to an older thread (posted as a question*).

Is the name of your Text item “Text” in the Hierarchy window? Whatever the name of the Gameobject is there, is what Unity will search for, in the scene.

@HaddicusGames yes text is sub-object of the gameobject convas for UI, To show the public text in the game

Bro!!!
What to do now!
Should i change the gameobject or in the base Gameobject.Find(), individually calling the components is’nt the right option!

But gamemanager=Gameojbect.Find(“Game Manager”).GetComponent() ;
Through it i call
Void AddScore() {
gamemanager.GmAddScore();
}

Aaaaahhhhh

Well, don’t freak out… What is null: the text object or the game manager? It should tell you in the console where the error is and you can double click to open it at that spot.
Just ensure that whatever is there isn’t null. :slight_smile:

@methos5k see this s.s !

3445136--272765--Ereror2.png

dragon falls down , and down down down down nd so on … to hell huh !!!

Do you find the game object in Awake?

void Start(){
myScore = 0;
myScoreGUI = GameObject.Find (“Text”).GetComponent ();
InvokeRepeating (“ObstacleSpawner”, .5f, 1.5f);
}
public void GmAddScore(){

this.myScore++;
myScoreGUI.text = myScore.ToString();
}

I meant the game manager being found…

NullReferenceException: Object reference not set to an instance of an object
ObstacleScript.AddScore () (at Assets/Scripts/ObstacleScript.cs:38)
ObstacleScript.Update () (at Assets/Scripts/ObstacleScript.cs:28)

this is the error!
it cannot find the object from gamemanager script and error generated in obstaclescript