`playerenter` event is showing `anonymous` even though i'm logged in

this script would fail because of it:

let key = { collection_id: 116, wearable_id: 16 };

parcel.on('playerenter', e => {
  const playerKey = e.player.collectibles.find(collectible => (collectible.collection_id === key.collection_id && collectible.wearable_id === key.wearable_id));
  if(playerKey) {
    feature.set({ collidable: false });
  } else {
    feature.set({ collidable: true });
  }
});

based on this tutorial: Limit interaction to some wallets | Cryptovoxels Wiki

Looks like async issue, I tried this:

let key = { collection_id: 116, wearable_id: 16 };

setTimeout(() => parcel.on('playerenter', e => {
  const playerKey = e.player.collectibles.find(collectible => (collectible.collection_id === key.collection_id && collectible.wearable_id === key.wearable_id));
  if(playerKey) {
    feature.set({ collidable: false });
  } else {
    feature.set({ collidable: true });
  }
}), 500);

didn’t work

What parcel is this script in? I tried to reproduce and couldn’t.
On another topic:
you could replace
e.player.collectibles.find(collectible => (collectible.collection_id === key.collection_id && collectible.wearable_id === key.wearable_id));
with
e.player.hasWearable([token_id],[ collection id])

Note that there is currently a bug due to a race condition when saving a script (the parcel-script reloads before the script is saved). Just click on the script field and click outside to cause a re-save

Thank you for the tips. Here’s the link to my parcel: Cryptovoxels

hmm does it still show as anonymous?
image
It show the right player name and all for me?
What browser are you using?

I’m using Chrome. It works when I first enter the parcel, but when I reload the page, it shows as anonymous.