I have an error "MissingReferenceException" and i dont know why

So…i creating an score and i works, when i kill the enemy it adds +10 to the score,when i get hit it quits 5 points to it, so everything works properly but i have this error all the time,i know my score works properly always but i dont understand why it appears. (Im new,maybe its just a silly error but i really dont know)


MissingReferenceException: The object of type ‘Text’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.EventSystems.UIBehaviour.IsActive () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/UIBehaviour.cs:22)
UnityEngine.UI.Graphic.SetVerticesDirty () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:100)
UnityEngine.UI.Text.set_text (System.String value) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Text.cs:138)
PlayerController.SetScore () (at Assets/PlayerController.cs:133)
PlayerController.OnBecameInvisible () (at Assets/PlayerController.cs:99)

You need to add a check on your script if enemy exists or not before accessing it’s text variable. What happens is that you destroyed the enemy game object but you have some functions trying to access that destroyed game object’s variables.