Spawn GameObject when Ray Collides

I want to create a Script, which spawns the GameObject “MainObject” at the position, where my Ray hits the GameObject with the Tag “Wall”. How can I do this?
At the moment I have this script:

    public string tag = "Wall";
    public GameObject MainObject;
    void Update()
    {
        if (Input.touchCount == 1)
        {
            Touch touched = Input.GetTouch(0);
            RaycastHit hitted;
            Ray ray = Camera.main.ScreenPointToRay(touched.position);

            if (Physics.Raycast(ray, out hitted, distance))
            {
                if (hitted.collider.CompareTag(tag))
                {
                    Vector3 create = new Vector3(touched.position.x,touched.position.y,0);

                    Instantiate(MainObject, create, Quaternion.identity);
                }
            }

        }



    }

The RaycastHit class provides useful information.
In your case, if hitted is not null, you can get the position with

hitted.point

Do you mean: Vector 3(hitted.point.x, hitted.point.y, hitted.point.z); ?

Yes, or just put:

Instantiate(MainObject, hitted.point, Quaternion.identity);

Ok, thx!