can someone help with this
i don't understand why placedBlocks is undefined even if placedBlocks.length is not 0
cannot read property 'split' of undefined at deleteBlocks
let placedBlocks = [];
world.afterEvents.blockPlace.subscribe(event => {
//...
placedBlocks = saveBlocks(event, placedBlocks);
});
world.beforeEvents.chatSend.subscribe((eventData) => {
//...
deleteBlocks(player, placedBlocks)
});
function saveBlocks (event, placedBlocks){
//...
let xyz = `${block.x} ${block.y} ${block.z}`;
placedBlocks.push(xyz);
return placedBlocks;
};
function deleteBlocks (player, placedBlocks){
for(let i=0; i=placedBlocks.length; i++){
let xyzSplit = placedBlocks[i].split(" ");
let blockLocation = xyzSplit.join(",");
World.getBlock(blockLocation).setType(MinecraftBlockTypes.air);
}
};