Making script working only for "raycasted" object

I am creating a 3D game, this part of scene will contain carrying a wood from forest to the camp. This script works if there is just one object with it, but I need many objects with that script.
If there is more of these objects all of them will become a child of a “character” and all will change rotation and position. What to do to make it working only for “raycasted” object?

if (Physics.Raycast(ray, out Hit, 15))
        {
            if (Hit.collider.tag == "beach_wood1")
            {
                GameObject.Find("crosshair").guiTexture.texture = Gt2D_c;
                if (Input.GetKeyDown(KeyCode.L))
                {
                    if (!isCarrying)
                    {
                        isCarrying = true;
                        var Char = GameObject.Find("Character");
                        var charRot = Char.transform.rotation;
                      //=>
                        rigidbody.isKinematic = true;
                        transform.parent = Char.transform;
                        transform.rotation = charRot;
                        transform.localPosition = new Vector3(5.075542f, -0.0920262f, -23.11452f);

                    }
                }
            }
        }

Hey,

I’m still learning this myself but I think you need to use the “HitInfo” Hit.transform as a reference to the object that you have hit and want to affect (make a child and move with the player). It’s the object that is “hit” by the ray cast that you want to affect right?

So, the script is attached to the camera and the camera is attached (child of) to the “Character” controller, so as the character moves the camera will move, right?

So try using Hit.transform.tag, Hit.transform.parent, etc… instead of just transform.parent, etc.

Here is a link to the doc info on rayCastHit Unity - Scripting API: RaycastHit