SendMessage execute function on all objects instead of one

Hi,
i’m using Raycast to detect object with tag “magicBox” - if object is detected i execute function in script attached to boxes tagged as “magicBox”. My problem is - SendMessage executes function on all boxes on scene - not as it supposed - only on one detected with Raycast. Any ideas ?

if(Physics.Raycast(transform.position, downVect, hit,10)){
    if(hit.collider.gameObject.tag == "magicBox"){
        hit.collider.gameObject.SendMessage("myFunction");
    }
}

Hi there, not really sure why it calls all the objects and not just one, but you could call the raycasted objects function directly and thereby not get this problem.

Like this:

if(Physics.Raycast(transform.position, downVect, hit,10)){
    if(hit.collider.gameObject.tag == "magicBox"){
        hit.collider.gameObject.GetComponent<ScriptName>().myFunction();
    }
}