#I need help with opening I UI when I punch a entity

1 messages · Page 1 of 1 (latest)

wicked bluff
#

"use strict";

import { Player, world } from "@minecraft/server";

world.afterEvents.entityHitEntity.subscribe(event => {
const attacker = event.damagingEntity;
const victim = event.hitEntity;

if (attacker instanceof Player) {
    if (victim.typeId == "blossom:ooga_npc") {
        attacker.sendMessage("You hit the Ooga NPC!");
    }
}

})

#

I have it so it says u hit oooga but I want a UI to Pop up

night leaf
# wicked bluff "use strict"; import { Player, world } from "@minecraft/server"; world.afterEv...
import { Player, world } from "@minecraft/server";
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";

world.afterEvents.entityHitEntity.subscribe(event => {
    const attacker = event.damagingEntity;
    const victim = event.hitEntity;

    if (attacker instanceof Player) {
        if (victim.typeId == "blossom:ooga_npc") {
            menu(player)
        }
    }
})

function menu(player) {
  let menu = new ActionFormData()
  menu.button('test')
  menu.show(player).then(data => {
    // code
  })
}