Array don't get values

Hello, i had this code

var existingFloor = app.root.findByName("Floor");

but if gave me undefined so i thought if it didn’t find any Floor entity didn’t work so i have changed in

var existingFloor = [];
existingFloor = app.root.findByName("Floor");

but nothing change so when i check the length i have an error coz it’s undefined…
https://playcanvas.com/editor/code/352037/Level.js
lines 386 and follows

Have you debugged you code?
https://developer.playcanvas.com/en/user-manual/scripting/debugging/

Adding breakpoint on existingFloor = app.root.findByName("Floor"); line and checking what value existingFloor will have after that line executed will give you a hint.

You assign value to variable, means you are redefining it.
Don’t forget to complete whole course on CodeAcademy on JS: https://www.codecademy.com/learn/learn-javascript As you are making simple JavaScript related mistakes that is basic to the language it self, not related to PlayCanvas.

Found the error 3 lines upper the one u mantioned…thanks for your kindness @max :slight_smile: