#for this code when i use the compass the gui doen't open can somebody help fix it

1 messages · Page 1 of 1 (latest)

cedar anvilBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1137324509603573762 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

warped sorrel
#

There's no such thing as interaction events.

#
world.afterEvents.interaction.subscribe(({ entity: player, type, target }) => {
  if (type !== "use_item" || target.typeId !== "minecraft:recovery_compass") return;
  if (player.hasTag('pvp')) return;
  Gui();
});
#

So I'll just drop this new one here:

#
world.afterEvents.itemUse.subscribe(({source,itemStack}) => {
  if (itemStack.typeId === "minecraft:compass" && !player.hasTag('pvp'))
  Gui(source); //Inserted the player instance
});
#

The function Gui() does not contain a parameter for the player instance, thus the form cannot be shown. Since the player is undefined inside the function.