click on screen to get the coordinate on the ground(x,z plane)

Hello, I am making 3D map. there is a ground on the x,z plane. I want to click on the ground, and to know which point on the ground i am clicking on. I am looking for the clicking point’s coordinate in the worldspace(x,0,z).
I am stuck in this problem for a week, I need your help. Thanks in advance. I

void Update(){
Ray ray =Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 100, LayerMask.NameToLayer(“Terrain”)))
{
Debug.Log(hit.point);
}
}

Use a ray cast from the mouse position onto the ground. the two things you might need to change are the 100 which is maximum distance the ray will travel and the layer name to whatever layer your ground is on.
See the docs for more detail: