Script not giving expected result

Hey guys, what did I wrong in this script?

PlayerMovement.attributes.add('turnSpeed', {type: 'number'});`
//rotation
if(this.app.keyboard.isPressed(pc.KEY_Q))
(
    this.entity.rigidbody.applyTorque(0,this.turnSpeed,0)
)
if(this.app.keyboard.isPressed(pc.KEY_E))
(
    this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0)
)

I need the character to turn around, but it doesn’t work.

Hi @m3168366 and welcome! :wave:

Your if statements use () instead of {}. In JavaScript, code blocks must use curly braces, otherwise the code inside will not execute correctly.

// rotation
if (this.app.keyboard.isPressed(pc.KEY_Q)) {
    this.entity.rigidbody.applyTorque(0, this.turnSpeed, 0);
}

if (this.app.keyboard.isPressed(pc.KEY_E)) {
    this.entity.rigidbody.applyTorque(0, -this.turnSpeed, 0);
}