#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)
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.