Error Message in multiplayer racing game

I keep getting an error while trying to make a racing multiplayer game here is the project and i will put the code below the picture

Game: PlayCanvas 3D HTML5 Game Engine

var Network = pc.createScript('network');

// static variables = null;
Network.socket = null;

// initialize code called once per entity
Network.prototype.initialize = function() {
    this.player ='Player');
    this.other ='Other');

    var socket = io.connect('!/trusted-unmarred-fiber?path=server.js%3A1%3A0'); // Glitch hosted server
    Network.socket = socket;
    socket.emit ('initialize');
    var self = this;
    socket.on ('playerData', function (data) {
        self.initializePlayers (data);

    socket.on ('playerJoined', function (data) {

    socket.on ('playerMoved', function (data) {

    socket.on ('killPlayer', function (data) {

Network.prototype.initializePlayers = function (data) {
    this.players = data.players; =;

    for(var id in this.players){
        if(id !={
            this.players[id].entity = this.createPlayerEntity(this.players[id]);

    this.initialized = true;

Network.prototype.addPlayer = function (data) {
    this.players[] = data;
    this.players[].entity = this.createPlayerEntity(data);

Network.prototype.movePlayer = function (data) {
    if (this.initialized && !this.players[].deleted) {
        this.players[].entity.rigidbody.teleport(data.x, data.y, data.z);

Network.prototype.removePlayer = function (data) {
    if (this.players[data].entity) {
        this.players[data].entity.destroy ();
        this.players[data].deleted = true;

Network.prototype.createPlayerEntity = function (data) {
    var newPlayer = this.other.clone();
    newPlayer.enabled = true;


    if (data)
        newPlayer.rigidbody.teleport(data.x, data.y, data.z);

    return newPlayer;

// update code called every frame
Network.prototype.update = function(dt) {

Network.prototype.updatePosition = function () {
    if (this.initialized) {    
        var pos = this.player.getPosition();
        Network.socket.emit('positionUpdate', {id:, x: pos.x, y: pos.y, z: pos.z});

I also cannot see the other player

Hi @Jack101,

I’m guessing you’re following this tutorial?

Under the section ‘Setting up the Project’ you’re asked to include the library under external scripts of your project’s settings. Can you confirm that you completed this step?

up not too sure but would you check it is this project

Screenshot 2022-03-25 9.43.08 PM
would it be this but i just put it there so ima check it out now i also put a new server because i was already using that server so i made a new one

yes i put it there but it did not fix the issue
any other possible issues?

Hi @Jack101,

Taking a look at your project, it seems like you placed this domain to load from your external scripts: //Personal link to project

This is not pointing to the script library that is used for If you take a closer look at the tutorial previously posted, you will see, that they provide you with a link to the script library that the tutorial uses. That is the link that should be place in your external scripts dialog:

I hope this is helpful.

ok thank you very much if it doesn’t work do you know what else it could be?

no its saying this

If you look at your error, it’s pointing to line 76 of your network.js file which looks like this:

When your adding a new player, are you sure that the entity that’s created for them has a rigidbody component?

let me check but it should

ok you saved me i just added and theres no error but im going to check if the muiltiplayer works real quick.

so theres no error but i can’t see the other player i will mess with the enabled to see if thats the issue

yeah that dident do anything it also got rid of the speed and buttons could you think of any other issues it could be?

should i try to fork the multiplayer tutorial and then copy all of the car and put it in that game and build from there if it works?

This is one of the complexities with multiplayer projects. They aren’t easy to get working quickly. If you play around with the multiplayer (definitely recommended because it is simple) you will see that not only does it create the capsule entities for each player, with all of their movement scripts for the individual joining the session, it also reports all of the movements to tall of the players and the positions of where everything is. Porting this over to the driving tutorial will be difficult because each individual car is moved using physics.

You will want to break up the behaviors that you are wanting to replicate into chunks and slowly integrate everything. It looks like the server receives the message that a player has left and therefore removes the UI for all of the players. Instead, you would want to ensure that you are only deleting the specific player’s car when the player leaves because the buttons are purely local.

Either way, if I were you, I wouldn’t focus to directly on attempting to sort out all of the logic on this project all at once at this point. There are so many moving parts, that it will make it quite difficult to find where all of the errors are really coming from. Instead, it may be easier to fork the multiplayer tutorial and study it, understanding how each piece of the code both on the server and in Playcanvas interacts with each other. Once you have a firm grasp of that, it will be much easier to then try and port similar logic over to a more complex project like this one. Remember, the players will need to know the position, speed, wheel direction, and more about the other players in the game with them. This won’t be a super easy task.

I hope this is helpful.

well thank you for trying to help and i will definitely take into consideration of what you have suggested to study