I don't know how to stop the mistakes in the console. No se como parar los mensajes de errores en la consola.

I have a videogame where there is a power up which if you touch it an object appear, and the object has a variable which is the same as the player, so if the variable of the player changes, the object’s variable too, but this object is no always in the scene, so it’s always trying to find the object to change the variable but if the object doesn’t exist, the console is sending a lot of mistakes every frame, and that is bad for the debug.log
I need a solution please, I thoughta a posible fix but it’s not my favorite, the idea is put a clone of the object in another place so the variables can be changed and there is not an error and how the object is in another place it does not bother. But I think that if I have a lot of objects and I do that with every object that is not always in the scene and I must do something similar the performance of the game won’t be good.

Necesito una solución por favor, pensé en una posible solución pero no es mi favorita, la idea es poner un clon del objeto en otro lugar para que las variables se puedan cambiar y no haya un error y cómo está el objeto en otro lugar. no molesta. Pero creo que si tengo muchos objetos y hago eso con todos los objetos que no siempre están en la escena y debo hacer algo similar, el rendimiento del juego no será bueno.

I haven’t seen the code, but the probable guess here is that the script on the player expects there to be an object which it can change the variable on. There are a couple ways to fix this, the simplest being:

Before you try and change the variable on the object, check if the object is null:

    if(object != null)  {
         // Update on object 
    } else {
         // Do nothing
    }