Getting where player hit in the viewport

as seen in the video when I click, I want a part to be created where I click and this part to appear in the viewport. Because I am currently working on a navigation system and I need it for pathfinding.

But i cant figure out how can i get the world position from that clicked position.