Call void for one Object

I have two gameObjects with a script named “Planet” and If I collide with one of these Objects I want to call a public void named “UpdateValues” in my Planet script, but it calls the void on both objects and I only want to call the void on the Object I collide with. here is My code:

            dockedPlanet = col.gameObject;
            planetscript = GameObject.Find(dockedPlanet.name).GetComponent<planet>();
            planetscript.UpdateValues();

any Solutions?

I was using Static variables and because of that, the scripts share the same variable. And because of that, it didn’t work