It probably doesn't work because the function is so fast... you need many loops to detect it properly. It's probably best to keep mouse button detection outside of a function.
set text opaque
Loops=0
do
text 0,0,"Number of loops: "+str$(Loops)
text 0,20,"Left Mouse Button Status: "+Info$
if mouseclick()=1
Info$="Pressed "
Pressed=1
endif
if Pressed=1 and mouseclick()=0
Info$="Released"
Pressed=0
endif
inc Loops
loop
You can also just stop all action till the mouse button is let go.
set text opaque
Loops=0
do
text 0,0,"Number of loops: "+str$(Loops)
text 0,20,"Left Mouse Button: Up "
if mouseclick()=1
text 0,20,"Left Mouse Button: Down"
repeat
until mouseclick()=0
endif
inc Loops
loop