# A error syntax in my code

**URL:** <https://forum.playcanvas.com/t/a-error-syntax-in-my-code/42644>\
**Category:** Help & Support\
**Tags:** learning, scripting\
**Created:** [October 2, 2026, 4:55pm UTC](https://forum.playcanvas.com/t/a-error-syntax-in-my-code/42644 "2026-10-02T16:55:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lea-Maude\_Lavigne\_Au](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/lea-maude_lavigne_au/32/38606_2.png) [@Lea-Maude\_Lavigne\_Au](https://forum.playcanvas.com/u/Lea-Maude_Lavigne_Au)\
**Post date:** [October 2, 2026, 4:55pm UTC](https://forum.playcanvas.com/t/a-error-syntax-in-my-code/42644/1 "2026-10-02T16:55:01Z")

</div>

```javascript
var Playermovement = pc.createScript(‘playermovement’);

Playermovement.attributes.add(‘movementSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘turnSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘jumpHeigth’, {type: ‘number’});

// initialize code called once per entity

Playermovement.prototype.initialize = function()

{

};

Playermovement.prototype.update = function(dt)

{

//movement

if (this.entity.name == (‘Player1’))

{

if (this.app.keyboard.isPressed(pc.KEY_S))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_W))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_A))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_D))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

//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)

}

var Playermovement = pc.createScript(‘playermovement’);

Playermovement.attributes.add(‘movementSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘turnSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘jumpHeigth’, {type: ‘number’});

// initialize code called once per entity

Playermovement.prototype.initialize = function()

{

};

Playermovement.prototype.update = function(dt)

{

//movement

if (this.entity.name == (‘Player1’))

{

if (this.app.keyboard.isPressed(pc.KEY_S))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_W))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_A))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_D))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

//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)

}

//else.if

if (this.entity.name == (‘Player2’))

{

if (this.app.keyboard.isPressed(pc.KEY_DOWN))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_UP))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_LEFT))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_RIGHT)) {

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

{

//rotation

{

if (this.app.keyboard.isPressed(pc.KEY_SHIFT)) {

this.entity.rigidbody.applyTorque(0,this.turnSpeed,0);

}

if (this.app.keyboard.isPressed(pc.KEY_CONTROL)) {

this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0);

}

{

//jump

{

if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {

this.entity.rigidbody.applyForce(0,this.jumpHeigth,0);

}

}

//else.if

if (this.entity.name == (‘Player2’))

{

if (this.app.keyboard.isPressed(pc.KEY_DOWN))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_UP))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_LEFT))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_RIGHT)) {

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

{

//rotation

{

if (this.app.keyboard.isPressed(pc.KEY_SHIFT)) {

this.entity.rigidbody.applyTorque(0,this.turnSpeed,0);

}

if (this.app.keyboard.isPressed(pc.KEY_CONTROL)) {

this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0);

}

{

//jump

{

if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {

this.entity.rigidbody.applyForce(0,this.jumpHeigth,0);

}

};

```

I can’t find where my error is it

Uncaught SyntaxError: Unexpected end of input

SyntaxError: Unexpected end of input

I don’t understand what exactly it mean it like my third day in coding and the video tutorial is two year old so i believe it migth be a language error but im not exactly

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [October 6, 2026, 4:53pm UTC](https://forum.playcanvas.com/t/a-error-syntax-in-my-code/42644/2 "2026-10-06T16:53:25Z")

</div>

Hi @Lea-Maude_Lavigne_Au and welcome! 👋

It looks like your code was pasted twice by mistake. Below the code I cleaned it up a bit and put it into one single script that should work. Please let me know if it works and send a link to your project if you need more help.

```javascript
var Playermovement = pc.createScript('playermovement');

Playermovement.attributes.add('movementSpeed', {type: 'number'});
Playermovement.attributes.add('turnSpeed', {type: 'number'});
Playermovement.attributes.add('jumpHeight', {type: 'number'});

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

// update code called every frame
Playermovement.prototype.update = function(dt) {
    // Movement for Player 1 (WASD)
    if (this.entity.name === 'Player1') {
        if (this.app.keyboard.isPressed(pc.KEY_S)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_W)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_A)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_D)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed));
        }

        // Rotation for Player 1 (Q/E)
        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);
        }

        // Jump for Player 1 (F)
        if (this.app.keyboard.wasPressed(pc.KEY_F)) {
            this.entity.rigidbody.applyForce(0, this.jumpHeight, 0);
        }
    }

    // Movement for Player 2 (Arrow keys)
    if (this.entity.name === 'Player2') {
        if (this.app.keyboard.isPressed(pc.KEY_DOWN)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_UP)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_LEFT)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_RIGHT)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed));
        }

        // Rotation for Player 2 (Shift/Ctrl)
        if (this.app.keyboard.isPressed(pc.KEY_SHIFT)) {
            this.entity.rigidbody.applyTorque(0, this.turnSpeed, 0);
        }
        if (this.app.keyboard.isPressed(pc.KEY_CONTROL)) {
            this.entity.rigidbody.applyTorque(0, -this.turnSpeed, 0);
        }

        // Jump for Player 2 (Space)
        if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
            this.entity.rigidbody.applyForce(0, this.jumpHeight, 0);
        }
    }
};

```
