Shift to sprint script not working

I have a shift to sprint script here, and every time I press shift, the game freezes, why is this happening?

The problem is that it enters the While loop, and can never leave.

change:

while (app.keyboard.isPressed(pc.input.KEY_SHIFT)) {
   speed = 10;
}

to:

if(app.keyboard.isPressed(pc.input.KEY_SHIFT)){
   this.speed = 10;
} else{
   this.speed = 5;
}
2 Likes

Because you have infinite loop. @el-pepi solution works.

1 Like