Straight shooting when mouse pressed(not held)

Hi, i’m fairly new to the unity community(just switched from game maker) and I’m trying to make a fps, but not with guns. I have the first person view down and all I want to do is whenever I click it creates a cube that moves to the mouse and I want the cube to get destroyed when it collides with a wall etc. Thank you so much

if(Input.getKeyDown(KeyCode.L)) {
//Code to shoot

This will shoot once the key “L” is pressed, but will only fire once if you hold it down, this function can be used for a mouse aswell, KeyCode.MouseButton0 i believe is left mouse.