# In the line where the error shows, wrap the code with system.run(() => {}) like that: system.run(() => { // the line that shows error })
# https://wiki.bedrock.dev/scripting/script-server#beforeevents-privilege-system Bedrock Wiki Script Core Features Introduction to some of the core API mechanics.