#I wanted to remove two player tags when they leave

1 messages · Page 1 of 1 (latest)

pulsar moss
#

I created a system that tries to remove just 1 tag but gives an error, can anyone help me and tell me why the error occurs?
my code
world.beforeEvents.playerLeave.subscribe((data) => {
const player = data.player.hasTag("form")
const remove = data.player.removeTag("form")
if (remove && player);
})

vital stream
#

It's a beforeEvent so you can't modify a player due to restrictions. Has to be done by offsetting the tick using system.run(), or in other cases passing it off to the afterEvent and handling it there whenever applicable.

I never used this event before but I wouldn't be surprised if it still fails to modify the player even after using system.run() since the player would no longer exist in the world by the time it decided to remove a tag.

vivid patrol
#

setDynamicProperty()
doesn't have this limitation, you can call them inside beforeEvents scope, maybe you should try to switch to these.

vital stream