Mouse event buttons problem

I want to make a script that hides the cursor if LMB is pressed.
Here is the code: (it isn’t attached to any entity)

var Mouse = pc.createScript('mouse');

// initialize code called once per entity
Mouse.prototype.initialize = function() {;

// update code called every frame
Mouse.prototype.update = function(dt) {
Mouse.prototype.mouseCheck = function(event){
    if(event.button === pc.MOUSEBUTTON_LEFT){;

The problem is that the right mouse button triggers the pc.MOUSEBUTTON_LEFT event button. The same goes for the pc.MOUSEBUTTON_MIDDLE event button.

If the script isn’t attached to any entity, then it doesn’t execute. Some other code is causing the issue.

(There are some code issues in what you have posted. I recommend reading this tutorial :slight_smile: