Space Ship Rotation

I am making a space shooter game and I would like my ship to move and rotate like a normal ship/plane. Pitch up and down already done, but I can not seem to figure out how to roll right and left, only regular turning. Basically I want to be able to do a barrel roll as the ship but the only way I know how is to use the rotateLocal(x, y, z) and this is both not smooth and does not work while pressing other input keys. I am using applyTorque(force_right) for example for my movement and it works very well, but I can only use this for up, down, left, and right, so no rotation. I am a beginner coder and I have only been doing this for about a week now so if anyone has a solution to my problem I would be ever so thankful.


TLDR; How do I add a movement script to my ship to make it barrel roll?

Base code:

var Fly = pc.createScript('fly');

Fly.attributes.add('speed', { type: 'number', default:500 });
Fly.attributes.add('camera', {type: 'entity'});
// initialize code called once per entity
Fly.prototype.initialize = function() {
    this.roll = 0;

Fly.prototype.localCameraUpdate = function(){
     // Change camera FOV based on speed of ship 
    var cameraEntity =; = 55 + (this.entity.rigidbody.linearVelocity.length() * 0.1);
    // Make camera rotate when moving left/right 
    var rollSpeed = 0.75;
    var rollMax = 30;
        this.roll += rollSpeed;
        //if(this.roll > rollMax) this.roll = rollMax;
    else if({ 
        this.roll -= rollSpeed;
        //if(this.roll < -rollMax) this.roll = -rollMax;
    this.roll *= 0.95;
    cameraEntity.setRotation(this.entity.getRotation()); // reset rotation
    cameraEntity.rotateLocal(-10, 0, this.roll);  
    var pos = new pc.Vec3(0,3,10);
    var newPos = new pc.Vec3(0,4,12);
    var speedFactor = this.entity.rigidbody.linearVelocity.length() / 170;
    pos.lerp(pos, newPos, speedFactor);

// update code called every frame
Fly.prototype.update = function(dt) {
    // Press Z to thrust 
    if( {
        //Move in the direction its facing
        var force = this.entity.forward.clone().scale(this.speed);
    // Update the camera
   // P to pause
        if( == 1){
   = 0;
        } else {
   = 1;
    // Rotate up/down/left/right    
        var force_up = this.entity.right.clone().scale(30);
        var force_down = this.entity.right.clone().scale(-30);
        // Rotate to the right
        var force_right = this.entity.up.clone().scale(-50);
        var force_left = this.entity.up.clone().scale(50);

Roll would be on the Z axis (the forward vector).

I understand that the roll is on the Z axis, and I have tried that with rotateLocal, but compared to the applyTorque(force_example) it does not work when pressing other input keys (Ex: Moving up and right at the same time), and it moves immediately rather than it having a smooth, natural turn.