[SOLVED] Scene change trigger errors

Hello guys, i am loosing my sanity, i have a button enter game that trigger the game scene after recovering the character from firebase, some changes ago it worked fine, now i have this log and i’m loosing my mind on it. any help is welcome- PlayCanvas | HTML5 Game Engine

 NetworkColyseus inizializzato NetworkColyseus.js:35:13
Content-Security-Policy warnings 5
An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. playcanvas-2.14.3.dbg.js:33403:24
Referrer Policy: Ignoring the less restricted referrer policy “origin-when-cross-origin” for the cross-site request: https://accounts.google.com/gsi/log?client_id=939860845686-8p2f6sq1ign0gccelskiernvmpps8ncl.apps.googleusercontent.com&as=INQgbG7rvp%2BhKCG0149YHG%2F1Crrt4Def5Ya%2FXaR69bo&bs=Ol6GLC5huVj%2FYFmtSKXIPu%2F7KXDylcM7zi%2BHIL7jdDw&event=onetap.closed.buttonFlowStarted&enable_itp_optimization=0 log
Storage access automatically granted for origin “https://accounts.google.com” on “https://launch.playcanvas.com”.
🔌 connectToServer() START NetworkColyseus.js:47:13
🔌 Tentativo connessione Colyseus... #1 NetworkColyseus.js:61:13
🔌 Client creato, joinOrCreate in arrivo... NetworkColyseus.js:67:17
Referrer Policy: Ignoring the less restricted referrer policy “origin-when-cross-origin” for the cross-site request: https://the5sealscolyseum-1.onrender.com/matchmake/joinOrCreate/my_room my_room
✅ Connessione riuscita alla room! VO3kB78k5 NetworkColyseus.js:71:17
🔍 checkCharacter() called oauth2.js:173:13
⏳ Room non pronta, checkCharacter in pending (OAuth) oauth2.js:179:17
🔥 Event network:connected fired NetworkColyseus.js:79:17
🔔 _registerRoomEvents() called NetworkColyseus.js:105:13
   room: VO3kB78k5 NetworkColyseus.js:106:13
🔥 Room events registered NetworkColyseus.js:83:17
📤 playerInfo inviato NetworkColyseus.js:91:17
📦 State iniziale ricevuto NetworkColyseus.js:109:17
   pendingCheckCharacter: true NetworkColyseus.js:110:17
   pendingCheckCharacter TRUE -> invio checkCharacter NetworkColyseus.js:114:21
🔍 requestCharacterCheck() called NetworkColyseus.js:238:13
   room: true connected: true state: true NetworkColyseus.js:239:13
📤 checkCharacter inviato NetworkColyseus.js:254:13
📌 characterExistence ricevuto (listener Oauth2): 
Object { exists: true, character: {…} }
oauth2.js:129:17
📌 characterExistence: 
Object { exists: true, character: {…} }
NetworkColyseus.js:152:17
🎯 Character ricevuto: 
Object { id: 0, user: "Hero", email: "", name: "Lisandro", race: "Human", sex: "M", clas: "Warrior", lang: "en", reputation: 0, strength: 5, … }
oauth2.js:15:17
✅ PlayerStat aggiornato con dati server 
Object { id: 0, user: "Hero", email: "", name: "Lisandro", race: "Human", sex: "M", clas: "Warrior", lang: "en", reputation: 0, strength: 5, … }
player_stat.js:318:13
Source map error: Error: URL constructor:  is not a valid URL.
Stack in the worker:resolveSourceMapURL@resource://devtools/client/shared/source-map-loader/utils/fetchSourceMap.js:56:22
getOriginalURLs@resource://devtools/client/shared/source-map-loader/source-map.js:75:24
workerHandler/</<@resource://devtools/client/shared/worker-utils.js:115:52
workerHandler/<@resource://devtools/client/shared/worker-utils.js:113:13

Resource URL: wasm:https://launch.playcanvas.com/api/assets/files/Ammo/ammo.wasm.js?id=34260228&branchId=ed280cef-e7f8-40e3-87ca-802dcd450d15&t=6b7ab3989e4f9f17c86e44380f9181c6%20line%20454%20%3E%20WebAssembly.Module
Source Map URL: null
DEPRECATED: pc.AppBase#getSceneUrl is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#find instead. debug.js:24:21
DEPRECATED: pc.AppBase#loadSceneHierarchy is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#loadSceneHierarchy instead. debug.js:24:21
script 'network' is not found, awaiting it to be added to registry debug.js:117:21
script 'uiBarBrowser' is not found, awaiting it to be added to registry debug.js:117:21
script 'uiBar' is not found, awaiting it to be added to registry debug.js:117:21
unhandled exception while calling "initialize" for "player" script:  TypeError: can't access property "findByName", this.model is undefined
    initialize player.js:253
    _scriptMethod component.js:463
    _onInitialize component.js:490
    _callComponentMethod system.js:147
    _onInitialize system.js:158
    fire event-handler.js:301
    _loaded scene-registry.js:320
    _preloadScripts app-base.js:745
    _loadSceneHierarchy scene-registry.js:328
    _loadSceneData scene-registry.js:231
    load viewport-scene-handler.ts:80
    setTimeout handler*load/</< viewport-scene-handler.ts:79
    o scene-loading.ts:56
    emitNone launch.js:253
    emit launch.js:346
    ingestSnapshot doc.js:237
    _handleSubscribe doc.js:323
    handleMessage connection.js:244
    onmessage connection.js:145
    onmessage realtime.ts:39
component.js:470:25
TypeError: can't access property "findByName", this.model is undefined
    initialize player.js:253
    _scriptMethod component.js:463
    _onInitialize component.js:490
    _callComponentMethod system.js:147
    _onInitialize system.js:158
    fire event-handler.js:301
    _loaded scene-registry.js:320
    _preloadScripts app-base.js:745
    _loadSceneHierarchy scene-registry.js:328
    _loadSceneData scene-registry.js:231
    load viewport-scene-handler.ts:80
    setTimeout handler*load/</< viewport-scene-handler.ts:79
    o scene-loading.ts:56
    emitNone launch.js:253
    emit launch.js:346
    ingestSnapshot doc.js:237
    _handleSubscribe doc.js:323
    handleMessage connection.js:244
    onmessage connection.js:145
    onmessage realtime.ts:39
viewport-error-console.ts:168:9
Referrer Policy: Ignoring the less restricted referrer policy “origin-when-cross-origin” for the cross-site request: https://ajax.googleapis.com/ajax/libs/webfont/1.6.16/webfont.js webfont.js
DEPRECATED: pc.GraphNode#setName is deprecated. Use pc.GraphNode#name instead. debug.js:24:21
Available voices: 
Array []
questSheet.js:29:13
DEPRECATED: Scene#fogColor is deprecated. Use Scene#fog.color instead. debug.js:24:21
FULL Create New Level-> Generate Level: 2ms - timer ended Level.js:124:21
DEPRECATED: pc.AppBase#loadSceneSettings is deprecated. Use pc.AppBase#scenes and pc.SceneRegistry#loadSceneSettings instead. debug.js:24:21
✅ Scene loaded: Game oauth2.js:219:21
✅ PlayerStat aggiornato con dati server 
Object { id: 0, user: "Hero", email: "", name: "Lisandro", race: "Human", sex: "M", clas: "Warrior", lang: "en", reputation: 0, strength: 5, … }
player_stat.js:318:13
CHARACTER FROM SERVER: 
Object { id: 0, user: "Hero", email: "", name: "Lisandro", race: "Human", sex: "M", clas: "Warrior", lang: "en", reputation: 0, strength: 5, … }
oauth2.js:237:29
WebGL warning: generateMipmap: Tex image TEXTURE_2D level 0 is incurring lazy initialization.
WebGL warning: drawElementsInstanced: Depth texture comparison requests (e.g. `LINEAR`) Filtering, but behavior is implementation-defined, and so on some systems will sometimes behave as `NEAREST`. (warns once)
WebGL warning: drawElementsInstanced: Tex image TEXTURE_2D level 0 is incurring lazy initialization.
WebGL warning: drawElementsInstanced: Tex image TEXTURE_2D level 0 is incurring lazy initialization.
Referrer Policy: Ignoring the less restricted referrer policy “origin-when-cross-origin” for the cross-site request: https://fonts.googleapis.com/css?family=Jura

Show the code for player.js initialize function please

here it is

var Player = pc.createScript('player');
Player.attributes.add("moveSpeed", {type:"number", default:0.15});
Player.attributes.add("walkAnimCutoff", {type:"number", default:0.8});
Player.attributes.add("blendTime", {type:"number", default:0.1});
Player.attributes.add('dbase', {type:"asset", assetType: 'json', array:true});
Player.attributes.add('Root', {type:"entity"});
Player.attributes.add('NewInv', {type:"entity"});
Player.attributes.add('camera', {type:"entity"});
Player.attributes.add('isLocalPlayer', { type: 'boolean', default: true });
    var temp = new pc.Vec3();
    var targID="";
    var targType="";
    var targObj="";
    var targDB="";
    var targPos = 0;
    var targPosition=0;

    var temp = new pc.Vec3();
    var rh=0;
    var tyn="";
    var zone = 70;
    var resistence=0;
    var SHIELD_SCALE_FACTOR = 111;
    var RAY_LENGTH = 50;
    var DOUBLE_CLICK_TIME = 0.3;
    var playerToEnemy= new pc.Vec3();
    
// initialize code called once per entity
Player.prototype.initialize = function() {
    this.combatManager = this.app.root.findByName('calc').script.combatManager;
    this.inCombat = false;
    this.targName = "";
        this.lv=0;
        this.base=true;
        this.x = 0;
        this.y = 0;
        this.depth=0;
        this.lastk=0;
        this.modeffect="";
        this.view=0;
        this.modificator=0;
        this.lang='en';
        this.name="Lisandro";
        this.race="Human";
        this.sex="M";
        this.clas="Ranger";
        this.reputation=0;
        //characteristics phisics
        this.strength=5;
        this.courage=5;
        this.fortune=5;
        //characteristics mental
        this.willing=4;
        this.inspiration=4;
        this.sensitivity=4;
        // illness
        this.venom=0;
        this.illness=0;
        // resistences
        this.Fire_resistence=0;
        this.Wind_resistence=0;
        this.Earth_resistence=0;
        this.Water_resistence=0;
        this.Energy_resistence=0;
        // world map
        this.wmap=0;
        this.wxmap=0;
        this.localMap=0;
        // food water level exp gold
        this.water=100;
        this.food=100;
        this.level=1;
        this.experience=0;
        this.gold=50;
        this.attac=3;
        this.defence=3;
        this.damage=3;
        this.armor=0;
        this.pmodel='HumanM';
        this.texTure="HumanM";
        this.clTexture="HumanM";
        //  abilities
        this.Mearth=0;
        this.hunting=3;
        this.huntingAdv=0;
        this.fishing=0;
        this.fishingAdv=0;
        this.orientate=0;
        this.orientateAdv=0;
        this.blades=0;
        this.bladesAdv=0;
        this.swordmanship=3;
        this.swordAdv=0;
        this.maces=0;
        this.macesAdv=0;
        this.hammers=0;
        this.hammersAdv=0;
        this.axes=0;
        this.axesAdv=0;
        this.poles=0;
        this.polesAdv=0;
        this.wArmour=0;
        this.armorAdv=0;
        this.aShield=0;
        this.shieldAdv=0;
        this.shooting=3;
        this.shotAdv=0;
        this.cooking=1;
        this.cookAdv=0;
        this.forging=2;
        this.forgeAdv=0;
        this.wilderness=0;
        this.wildAdv=0;
        this.herbs=1;
        this.herbsAdv=0;
        this.leather=0;
        this.leatherAdv=0;
        this.picklock=0;
        this.plockAdv=0;
        this.shadows=0;
        this.shadowAdv=0;
        this.shadowtiming=0;
        this.shanea=0;
        this.lemanghan=0;
        this.riannon=0;
        this.holiness=0;
        this.Mair=0;
        this.Menergy=0;
        this.Mfire=0;
        this.Mwater=0;
        this.receipt=0; // in database receipt id must start from 1
        this.crafting="";
        this.potion=0;
        this.foritem=0;
        this.shopType = "";
        this.helm=null;
        this.shield=null;
        this.sword=null;
        this.bow=null;
        this.quiver=null;
        this.rayStart = new pc.Vec3();
        this.rayEnd = new pc.Vec3();
        this.combat=0;
        this.actTime=0;
        this.clickTimer = 0;
        this.clicked = null;
        this.pos = null;
        this.lastPos = new pc.Vec3();
        this.state = "idle";
        this.status="";
        this.startPosition = new pc.Vec3();
        this.targetPosition = new pc.Vec3();
        this.target=null;
        this.moveTimer = 0;
        this.ignoreMouse = false;
        this.head=null;
        this.lhand=null;
        this.rhand=null;
        this.pouch=null;
        this.back=null;
        this.arrow=null;
        this.set=1;
        this.wRange=0;
        this.wDamage=6;
        this.inventoryOpen=false;
        this.characterOpen=false;
        this.abilityOpen=false;
        this.spellOpen=false;
        this.questOpen=false;
        this.shopOpen=false;
        this.loadOpen=false;
        this.inventory=[];
        this.dataWeapons=[];
        this.dataPotions=[];
        this.dataShields=[];
        this.dataArmours=[];
        this.dataBoots=[];
        this.dataRings=[];
        this.dataNeck=[];
        this.dataItems=[];
        this.dataFood=[];
        this.dataIngredients=[];
        this.dataReceipts =[];
        this.dataHerbs=[];
        this.dataHerbalist=[];
        this.dataMerchant=[];
        this.dataDishes = [];
        this.dataResources= [];
        this.dataMagic=[];
        this.dataHolySp=[];
        this.dataInn=[];
        this.dataNPC=[];
        this.dataShops=[];
        this.dataWarnings=[];
        this.dialogue=[];
        this.tickEffects = [];
        this.quests=[];
        this.visibilityRange=5;
        this.lootUID=6;
        this.ability=[];
        this.selAbility=[];
        this.spells=[];
        this.selSpell=[];
        this.training="";
        this.spellActive="";
        this.teleport=false;
        this.timeStart=0;
        this.track=[];
        this.iconKey=0;
        this.iconRocks=0;
        this.orTime=null;
        this.wilTime=null;
        var app= this.app;
        if (this.lang==='en') {
                var dbase = this.dbase[0].resource;
            } else if (this.lang==='it') {
                var dbase = this.dbase[1].resource;
            } else if (this.lang==='de') {
                var dbase = this.dbase[2].resource;
            }
            this.game = this.Root.script.game;
            // Parse JSON data
            var oggdata = this.parseCharacterData(dbase);
            this.app.mouse.disableContextMenu();
            //this.loadStats();
            this.start();
            this.clickable=false;
            this.startPosition = this.entity.getPosition();
            this.startRotation = this.entity.getRotation();
            this.entity.rigidbody.syncEntityToBody();
            this.entity.collision.on('collisionstart', this.onCollisionStart, this);
            // assign shield to left hand
            // resize small shield for now waiting to find a different way
            this.shield=this.entity.findByName("towershield");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50);
            this.shield=this.entity.findByName("phoenixshield");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50);
            this.shield=this.entity.findByName("largeshield");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("pavese");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("pavese1");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("smallround");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("buckler");
            this.lhand = this.model.findByName('Bip01 I Mano');
            this.shield.reparent(this.lhand);
            this.shield.setLocalPosition(4,-4,-0.2);
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40);
            if (this.equipped.SHIELD!==0) {
                this.equip_shield(this.equipped.SHIELD.obj);
            }
            // assign arrow pouch to back
            this.pouch=this.entity.findByName("quiver");
            this.back = this.model.findByName('Bip01 Columna3');
            this.pouch.reparent(this.back);
            this.pouch.setLocalPosition(-15,-20,0);
            var pscale = this.pouch.getWorldTransform().getScale();
            this.pouch.setLocalScale(15/pscale.x, 15/pscale.y, 15/pscale.z);
            // assign bow to back
            this.bow=this.entity.findByName("bow");
            var bscale = this.bow.getWorldTransform().getScale();
            this.bow.setLocalScale(1500, 1500, 1500);
            this.bow=this.entity.findByName("longbow");
            var bscale = this.bow.getWorldTransform().getScale();
            this.bow.setLocalScale(1500,1500,1500);
            this.bow=this.entity.findByName("shortbow");
            this.bow.reparent(this.back);
            this.bow.setLocalPosition(-20,-20,0);
            var bscale = this.bow.getWorldTransform().getScale();
            this.bow.setLocalScale(1400,1400,1400);
            if (this.equipped.WEAPON2.type==='BOW') {
                this.bow.enabled=true;
                this.pouch.enabled=true;
            } 
            // assign sword to right hand
            this.sword=this.entity.findByName("hammer");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(50, 50, 50);
            this.sword=this.entity.findByName("Hammerw");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(50, 50, 50);
            this.sword=this.entity.findByName("spear");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(70, 70, 70);
            this.sword=this.entity.findByName("holycane");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(9000, 9000, 9000);
            this.sword=this.entity.findByName("rowanstaff");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(8000, 8000, 8000);
            this.sword=this.entity.findByName("hatchet");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(70, 70, 70);
            this.sword=this.entity.findByName("axe");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(50, 50, 50);
            this.sword=this.entity.findByName("mace");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(4200, 4200, 4200);
            this.sword=this.entity.findByName("waraxe");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR, SHIELD_SCALE_FACTOR-15);
            this.sword=this.entity.findByName("morningstar");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-350, SHIELD_SCALE_FACTOR-350, SHIELD_SCALE_FACTOR-350);
            this.sword=this.entity.findByName("broadsword");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR, SHIELD_SCALE_FACTOR-15);
            this.sword=this.entity.findByName("longsword");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR-15);
            this.sword=this.entity.findByName("claymore");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-55, SHIELD_SCALE_FACTOR-55, SHIELD_SCALE_FACTOR-55);
            this.sword=this.entity.findByName("dagger");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-25, SHIELD_SCALE_FACTOR-25, SHIELD_SCALE_FACTOR-25);
            this.sword=this.entity.findByName("knife");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40);
            this.sword=this.entity.findByName("shortsword");
            this.rhand = this.model.findByName('Bip01 D Mano');
            //console.log(this.lhand);
            this.sword.reparent(this.rhand);
            //this.sword.setLocalPosition(10,-4,-1);
            //this.sword.setLocalEulerAngles(100, 0, 45);
            var sscale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10);
            this.sword=this.entity.findByName(this.equipped.WEAPON.name);
            this.sword=this.entity.findByName("windsword");
            this.rhand = this.model.findByName('Bip01 D Mano');
            this.sword.reparent(this.rhand);
            var sscale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10);
            this.sword=this.entity.findByName(this.equipped.WEAPON.name);
            if (this.equipped.WEAPON.type==='BLADE' || this.equipped.WEAPON.type==='SWORD' || this.equipped.WEAPON.type==='AXE' || this.equipped.WEAPON.type==='HAMMER' || this.equipped.WEAPON.type==='MACE') {
                this.equip_sword(this.equipped.WEAPON.obj,this.equipped.WEAPON.type);
            }
            if (this.sword) {
            this.sword.enabled=true;
            }
            this.force = new pc.Vec3();
};

It don’t know why that happens, maybe the model is not loaded?

ok, i tried a workaround of the problem, I have split the initialize like this

var Player = pc.createScript('player');
Player.attributes.add("moveSpeed", {type:"number", default:0.15});
Player.attributes.add("walkAnimCutoff", {type:"number", default:0.8});
Player.attributes.add("blendTime", {type:"number", default:0.1});
Player.attributes.add('dbase', {type:"asset", assetType: 'json', array:true});
Player.attributes.add('Root', {type:"entity"});
Player.attributes.add('NewInv', {type:"entity"});
Player.attributes.add('camera', {type:"entity"});
Player.attributes.add('isLocalPlayer', { type: 'boolean', default: true });
    var temp = new pc.Vec3();
    var targID="";
    var targType="";
    var targObj="";
    var targDB="";
    var targPos = 0;
    var targPosition=0;

    var temp = new pc.Vec3();
    var rh=0;
    var tyn="";
    var zone = 70;
    var resistence=0;
    var SHIELD_SCALE_FACTOR = 111;
    var RAY_LENGTH = 50;
    var DOUBLE_CLICK_TIME = 0.3;
    var playerToEnemy= new pc.Vec3();
    
// initialize code called once per entity
Player.prototype.initialize = function() {
    this.combatManager = this.app.root.findByName('calc').script.combatManager;
    this.inCombat = false;
    this.targName = "";
        this.lv=0;
        this.base=true;
        this.x = 0;
        this.y = 0;
        this.depth=0;
        this.lastk=0;
        this.modeffect="";
        this.view=0;
        this.modificator=0;
        this.lang='en';
        this.name="Lisandro";
        this.race="Human";
        this.sex="M";
        this.clas="Ranger";
        this.reputation=0;
        //characteristics phisics
        this.strength=5;
        this.courage=5;
        this.fortune=5;
        //characteristics mental
        this.willing=4;
        this.inspiration=4;
        this.sensitivity=4;
        // illness
        this.venom=0;
        this.illness=0;
        // resistences
        this.Fire_resistence=0;
        this.Wind_resistence=0;
        this.Earth_resistence=0;
        this.Water_resistence=0;
        this.Energy_resistence=0;
        // world map
        this.wmap=0;
        this.wxmap=0;
        this.localMap=0;
        // food water level exp gold
        this.water=100;
        this.food=100;
        this.level=1;
        this.experience=0;
        this.gold=50;
        this.attac=3;
        this.defence=3;
        this.damage=3;
        this.armor=0;
        this.pmodel='HumanM';
        this.texTure="HumanM";
        this.clTexture="HumanM";
        //  abilities
        this.Mearth=0;
        this.hunting=3;
        this.huntingAdv=0;
        this.fishing=0;
        this.fishingAdv=0;
        this.orientate=0;
        this.orientateAdv=0;
        this.blades=0;
        this.bladesAdv=0;
        this.swordmanship=3;
        this.swordAdv=0;
        this.maces=0;
        this.macesAdv=0;
        this.hammers=0;
        this.hammersAdv=0;
        this.axes=0;
        this.axesAdv=0;
        this.poles=0;
        this.polesAdv=0;
        this.wArmour=0;
        this.armorAdv=0;
        this.aShield=0;
        this.shieldAdv=0;
        this.shooting=3;
        this.shotAdv=0;
        this.cooking=1;
        this.cookAdv=0;
        this.forging=2;
        this.forgeAdv=0;
        this.wilderness=0;
        this.wildAdv=0;
        this.herbs=1;
        this.herbsAdv=0;
        this.leather=0;
        this.leatherAdv=0;
        this.picklock=0;
        this.plockAdv=0;
        this.shadows=0;
        this.shadowAdv=0;
        this.shadowtiming=0;
        this.shanea=0;
        this.lemanghan=0;
        this.riannon=0;
        this.holiness=0;
        this.Mair=0;
        this.Menergy=0;
        this.Mfire=0;
        this.Mwater=0;
        this.receipt=0; // in database receipt id must start from 1
        this.crafting="";
        this.potion=0;
        this.foritem=0;
        this.shopType = "";
        this.helm=null;
        this.shield=null;
        this.sword=null;
        this.bow=null;
        this.quiver=null;
        this.rayStart = new pc.Vec3();
        this.rayEnd = new pc.Vec3();
        this.combat=0;
        this.actTime=0;
        this.clickTimer = 0;
        this.clicked = null;
        this.pos = null;
        this.lastPos = new pc.Vec3();
        this.state = "idle";
        this.status="";
        this.startPosition = new pc.Vec3();
        this.targetPosition = new pc.Vec3();
        this.target=null;
        this.moveTimer = 0;
        this.ignoreMouse = false;
        this.head=null;
        this.lhand=null;
        this.rhand=null;
        this.pouch=null;
        this.back=null;
        this.arrow=null;
        this.set=1;
        this.wRange=0;
        this.wDamage=6;
        this.inventoryOpen=false;
        this.characterOpen=false;
        this.abilityOpen=false;
        this.spellOpen=false;
        this.questOpen=false;
        this.shopOpen=false;
        this.loadOpen=false;
        this.inventory=[];
        this.dataWeapons=[];
        this.dataPotions=[];
        this.dataShields=[];
        this.dataArmours=[];
        this.dataBoots=[];
        this.dataRings=[];
        this.dataNeck=[];
        this.dataItems=[];
        this.dataFood=[];
        this.dataIngredients=[];
        this.dataReceipts =[];
        this.dataHerbs=[];
        this.dataHerbalist=[];
        this.dataMerchant=[];
        this.dataDishes = [];
        this.dataResources= [];
        this.dataMagic=[];
        this.dataHolySp=[];
        this.dataInn=[];
        this.dataNPC=[];
        this.dataShops=[];
        this.dataWarnings=[];
        this.dialogue=[];
        this.tickEffects = [];
        this.quests=[];
        this.visibilityRange=5;
        this.lootUID=6;
        this.ability=[];
        this.selAbility=[];
        this.spells=[];
        this.selSpell=[];
        this.training="";
        this.spellActive="";
        this.teleport=false;
        this.timeStart=0;
        this.track=[];
        this.iconKey=0;
        this.iconRocks=0;
        this.orTime=null;
        this.wilTime=null;
        var app= this.app;
        if (this.lang==='en') {
                var dbase = this.dbase[0].resource;
            } else if (this.lang==='it') {
                var dbase = this.dbase[1].resource;
            } else if (this.lang==='de') {
                var dbase = this.dbase[2].resource;
            }
            this.game = this.Root.script.game;
            // Parse JSON data
            var oggdata = this.parseCharacterData(dbase);
            this.app.mouse.disableContextMenu();
            //this.loadStats();
            this.start();
            this.clickable=false;
            this.startPosition = this.entity.getPosition();
            this.startRotation = this.entity.getRotation();
            this.entity.rigidbody.syncEntityToBody();
            this.entity.collision.on('collisionstart', this.onCollisionStart, this);
            // assign shield to left hand
            // resize small shield for now waiting to find a different way
            this.waitForModel();
            this.force = new pc.Vec3();
};

Player.prototype.waitForModel = function() {
    // Se non hai ancora il model, riprova al prossimo frame
    if (!this.model) {
        this.app.once('postupdate', this.waitForModel, this);
        return;
    }

    this.setupEquipment();
};

Player.prototype.setupEquipment = function() {
     this.shield=this.entity.findByName("towershield");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50);
            this.shield=this.entity.findByName("phoenixshield");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50, SHIELD_SCALE_FACTOR+50);
            this.shield=this.entity.findByName("largeshield");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("pavese");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("pavese1");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("smallround");
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30, SHIELD_SCALE_FACTOR-30);
            this.shield=this.entity.findByName("buckler");
            this.lhand = this.model.findByName('Bip01 I Mano');
            this.shield.reparent(this.lhand);
            this.shield.setLocalPosition(4,-4,-0.2);
            var scale = this.shield.getWorldTransform().getScale();
            this.shield.setLocalScale(SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40);
            if (this.equipped.SHIELD!==0) {
                this.equip_shield(this.equipped.SHIELD.obj);
            }
            // assign arrow pouch to back
            this.pouch=this.entity.findByName("quiver");
            this.back = this.model.findByName('Bip01 Columna3');
            this.pouch.reparent(this.back);
            this.pouch.setLocalPosition(-15,-20,0);
            var pscale = this.pouch.getWorldTransform().getScale();
            this.pouch.setLocalScale(15/pscale.x, 15/pscale.y, 15/pscale.z);
            // assign bow to back
            this.bow=this.entity.findByName("bow");
            var bscale = this.bow.getWorldTransform().getScale();
            this.bow.setLocalScale(1500, 1500, 1500);
            this.bow=this.entity.findByName("longbow");
            var bscale = this.bow.getWorldTransform().getScale();
            this.bow.setLocalScale(1500,1500,1500);
            this.bow=this.entity.findByName("shortbow");
            this.bow.reparent(this.back);
            this.bow.setLocalPosition(-20,-20,0);
            var bscale = this.bow.getWorldTransform().getScale();
            this.bow.setLocalScale(1400,1400,1400);
            if (this.equipped.WEAPON2.type==='BOW') {
                this.bow.enabled=true;
                this.pouch.enabled=true;
            } 
            // assign sword to right hand
            this.sword=this.entity.findByName("hammer");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(50, 50, 50);
            this.sword=this.entity.findByName("Hammerw");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(50, 50, 50);
            this.sword=this.entity.findByName("spear");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(70, 70, 70);
            this.sword=this.entity.findByName("holycane");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(9000, 9000, 9000);
            this.sword=this.entity.findByName("rowanstaff");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(8000, 8000, 8000);
            this.sword=this.entity.findByName("hatchet");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(70, 70, 70);
            this.sword=this.entity.findByName("axe");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(50, 50, 50);
            this.sword=this.entity.findByName("mace");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(4200, 4200, 4200);
            this.sword=this.entity.findByName("waraxe");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR, SHIELD_SCALE_FACTOR-15);
            this.sword=this.entity.findByName("morningstar");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-350, SHIELD_SCALE_FACTOR-350, SHIELD_SCALE_FACTOR-350);
            this.sword=this.entity.findByName("broadsword");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR, SHIELD_SCALE_FACTOR-15);
            this.sword=this.entity.findByName("longsword");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR-15, SHIELD_SCALE_FACTOR-15);
            this.sword=this.entity.findByName("claymore");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-55, SHIELD_SCALE_FACTOR-55, SHIELD_SCALE_FACTOR-55);
            this.sword=this.entity.findByName("dagger");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-25, SHIELD_SCALE_FACTOR-25, SHIELD_SCALE_FACTOR-25);
            this.sword=this.entity.findByName("knife");
            var scale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40, SHIELD_SCALE_FACTOR-40);
            this.sword=this.entity.findByName("shortsword");
            this.rhand = this.model.findByName('Bip01 D Mano');
            //console.log(this.lhand);
            this.sword.reparent(this.rhand);
            //this.sword.setLocalPosition(10,-4,-1);
            //this.sword.setLocalEulerAngles(100, 0, 45);
            var sscale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10);
            this.sword=this.entity.findByName(this.equipped.WEAPON.name);
            this.sword=this.entity.findByName("windsword");
            this.rhand = this.model.findByName('Bip01 D Mano');
            this.sword.reparent(this.rhand);
            var sscale = this.sword.getWorldTransform().getScale();
            this.sword.setLocalScale(SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10, SHIELD_SCALE_FACTOR-10);
            this.sword=this.entity.findByName(this.equipped.WEAPON.name);
            if (this.equipped.WEAPON.type==='BLADE' || this.equipped.WEAPON.type==='SWORD' || this.equipped.WEAPON.type==='AXE' || this.equipped.WEAPON.type==='HAMMER' || this.equipped.WEAPON.type==='MACE') {
                this.equip_sword(this.equipped.WEAPON.obj,this.equipped.WEAPON.type);
            }
            if (this.sword) {
            this.sword.enabled=true;
            }
};

then since i had a problem with the model i added in my oauth this when the enter game button is pressed

 var playerEntity = self.app.root.findByName('Player');
                    if (!playerEntity) {
                        console.error("❌ Player entity not found!");
                        return;
                    }
                    var mod=characterData.race+characterData.sex;
                    var model=playerEntity.findByName(mod);
                    model.enabled=true;
                    playerEntity.script.model=model;
                    // Abilita player solo DOPO che gli script sono pronti
                    playerEntity.enabled = true;

                    // Aspetta che lo script "player" sia inizializzato
                    playerEntity.once('script:initialize', function() {
                        playerEntity.script.player.loadStats();

                        // OK ora è sicuro chiamare gli altri metodi
                        if (playerEntity.script.phealth) playerEntity.script.phealth.startingset();
                        if (playerEntity.script.player) playerEntity.script.player.respawn();

                        self.app.root.findByName('Camera').enabled = true;
                        self.app.root.findByName('Root').script.gui.createIcons();
                        self.app.root.findByName('Root').script.output.reboot();

                        window.NetworkColyseusInstance.sceneReady = true;
                        console.log("🎮 Gioco avviato!");
                    });

the scene is loaded, the player is visible, but when i click to move i get



[player.js?id=29542731&branchId=ed280cef-e7f8-40e3-87ca-802dcd450d15:3783]: TypeError: can't access property "animation", this.model is undefined

Player.prototype.moveTo@https://launch.playcanvas.com/api/assets/files/Scripts/player.js?id=29542731&branchId=ed280cef-e7f8-40e3-87ca-802dcd450d15:3783:13
Player.prototype.onRayHit@https://launch.playcanvas.com/api/assets/files/Scripts/player.js?id=29542731&branchId=ed280cef-e7f8-40e3-87ca-802dcd450d15:4520:22
Player.prototype.onMouseDown@https://launch.playcanvas.com/api/assets/files/Scripts/player.js?id=29542731&branchId=ed280cef-e7f8-40e3-87ca-802dcd450d15:3855:38
fire@https://code.playcanvas.com/playcanvas-2.14.3.dbg.js:1734:27
_handleDown@https://code.playcanvas.com/playcanvas-2.14.3.dbg.js:30897:15

i want to cry, it worked for 8 years

In the first version of the script, I can’t see where you give this.model a value or an object reference. ie you don’t do this.model = before you use it in the initialise function

Yes @yaustar the definition is in another script

               this.app.root.findByName('Player').enabled=true;
               this.app.root.findByName('Player').script.Phealth.startingset();
               this.app.root.findByName('Player').script.player.loadStats();
               this.app.root.findByName('Player').script.player.resetCamera('CameraD');
               this.app.root.findByName('Player').script.player.respawn();
               this.app.root.findByName('Root').script.gui.createIcons();
               this.app.root.findByName('Root').script.Output.reboot();

in loadstats there is

            this.model = this.entity.findByName(this.pmodel);
            this.model.enabled=true;

where this.pmodel = this.race+this.sex
the starting model is now loaded, but when the animation is applied (walkto for example) the model is missing again

moveTo called | this: 
Object { _callbacks: Map(0), _callbackActive: Map(0), app: {…}, entity: {…}, _enabled: true, _enabledOld: true, __destroyed: false, __scriptType: scriptType(args), __executionOrder: 0, __attributes: {…}, … }
player.js:3778:22
model: undefined player.js:3779:21
Uncaught TypeError: can't access property "animation", this.model is undefined
    moveTo player.js:3783
    onRayHit player.js:4520
    onMouseDown player.js:3855
    fire event-handler.js:301
    _handleDown mouse.js:308

ho yes i also added the definition of this model in the oauth before calling the player.enabled to have already the model defined.

What script is this code in? Because this is likely where your issue is

well seems i had a bit of issues, wait i will be back at you shortly

@yaustar ok now everything works as before, for some reasone this.model disapeared from the variables declarations, i had a leftover of a network script that wasn’t necessary anymore, and so all the bugs disapeared.
3 days lost for nothing. sigh. Thanks anyway Yaustar