Ask coding questions

← Back to all posts
How do I use getclick() in Basic?
h
UCYT5040

I have this code on loop.
print getclick()
It returns 0: clickx, 1: clicky or 0: 10, 1: 20, but when I use print getclick()[0] attempting to get the x postion, I get RuntimeError: Error on line 5: Error evaluating __pgb.fun("GETCLICK")().get(0). I have also tried getclick(0), but this does nothing. How can I get the x or y position of the click?

Answered by SixBeeps [earned 5 cycles]
View Answer
Voters
Unknownbinary2
UCYT5040
Comments
hotnewtop
SixBeeps

GetClick() will only return something if there was a click on that frame. So, you'll have to do some checking to see if there is any content: