Input.GetMouseButtonDown(0) not working

I have this script :

if(Input.GetMouseButtonDown(0)) {
   //some more stuff

For some reason, the click just doesn’t work. I put the debug.log thing on purpose because I want to see if it actually detects the click. No it didn’t. No errors or anything. when I clicked it the debug log showed nothing. I don’t get why it doesn’t work. Does anyone have any ideas? Thank You very much

If you want this to work only once then take one boolean variable.

public boolean allowClick = true;

Void Update()
                       //do stuff here
                       allowClick = false;

"You need to call this function from the Update function, since the state gets reset each frame. It will not return true until the user has released the mouse button and pressed it again. "

Do you have it in your Update or anywhere else? :slight_smile:

Scoure: Unity - Scripting API: Input.GetMouseButtonDown

put it in update function on code of a gameobject that is enabled.