So you can post code on the forum by typing 3 tildes ~~~ on a line by themselves, directly above and directly below the code text. This makes it easier to read and search.
To answer your question. mouseClick
is always zero. It helps to read the code from the top and loop through it a few times in your mind. The first frame, it is 0 (because that is what you define at the top of the script) and the mouse has not been clicked or checked yet. The first if fails, so nothing is changed. The second if is true, because mouseClick is 0. So we set it to 1. But on the next if we check if it is 1 (it is) so we set it to 0. Then we do the input check. If the mouse was pressed, it will be 1, if not it will be 0. Since we just traced all the code, we know setting it to 0, it will always remain 0. If we set it to 1, then, on the next frame it reaches the first if and is set to 0. So, no matter what happens. mouseClick is 0. So the logic doesn't make sense.
There are two ways to fix this. You can use a boolean flag (true or false) do track the clicks. This is a good idea when there are only 2 states, or you want to toggle something. But in this case, you only need the values 1 and -1, so there is an easier way to do it. This would be the code. This should go after the move_and_slide call and replace everything else.
# at top of script
var direction = 1.0
# in physics process after move and slide
velocity.x += direction
if Input.is_action_pressed("left_mouse"):
direction *= -1.0