script doesn't work on the right object in unity

What to do to make my object in the game “log” compatible with my script which causes the flashing of the object ?
this my script:

[SerializeField] private SimpleFlash flashEffect; 
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //we don't even want to detect collisions when the knife isn't active
        if (!isActive)
            return;
        
         
        
         
        //if the knife happens to be active (1st collision), deactivate it
        isActive = false;

        //collision with a log
        if (collision.collider.tag == "Log")
        {
            flashEffect.Flash();
            GetComponent<ParticleSystem>().Play();
            bezLOSoundEffect.Play();
            
            
            //stop the knife
            rb.velocity = new Vector2(0, 0);
            //this will automatically inherit rotation of the new parent (log)
            rb.bodyType = RigidbodyType2D.Kinematic;
            transform.SetParent(collision.collider.transform);

            //move the collider away from the blade which is stuck in the log
            knifeCollider.offset = new Vector2(knifeCollider.offset.x, -0.4f);
            knifeCollider.size = new Vector2(knifeCollider.size.x, 1.2f);

            //Spawn another knife
            GameController.Instance.OnSuccessfulKnifeHit();
        }

It is mainly about the line: flashEffect.Flash();
The script is in a different inspector, so it works on the wrong object. I’ve tried these ways, but I always get an error or it just doesn’t work.
flashEffect.Flash(log);
flashEffect.Flash(“log”);
flashEffect.Flash(log.gameObject);
flashEffect.Flash(log.gameObject);

Communicating between Game Objects is a BIG topic. Although you can use public and statics to call directly or use SendMessage, neither of these is the pro way of doing it. One commonly used technique is C# Events.

When something happens (eg stab with the knife), send an event to say it’s happened and other classes can subscribe (i.e. choose to listen) to the event. This separates code and is fully expandable.

Your calling code could look like this:

using System;
using UnityEngine;

public class Player : MonoBehaviour
{
    public static event Action<GameObject> createFlash;

    private void OnCollisionEnter(UnityEngine.Collision collision)
    {
        createFlash?.Invoke(collision.gameObject);
    }
}

What’s going on here? We create an event called createFlash which receives a GameObject as a parameter. It’s the Action keyword that defines the signature (i.e. what parameter types are passed). When we have a collision, we want to invoke the event but only if someone, somewhere is listening to the event. The slightly strange syntax in the Invoke checks to make sure that someone has actually subscribed and, if not, it doesn’t create the event. In case you haven’t seen this before, the question mark is called the Null-conditional Operator

Your flasher code in a separate class might look like this:

using UnityEngine;

public class Flasher : MonoBehaviour
{
    private void OnEnable()
    {
        Player.createFlash += Flash;
    }

    private void OnDisable()
    {
        Player.createFlash -= Flash;
    }

    void Flash(GameObject target)
    {
        print("You can now reference " + target);
    }
}

You have to subscribe to the event and you do this in the OnEnable event. Make sure that you unsubscribe as well in OnDisable, in case you ever destroy this game object. It’s good practice to do this. When you subscribe, point at the method that will handle the event and make sure that it has the same signature (i.e. same parameters) as the event definition above.

Come back if you have any problems…