HyperScript
Docs

← All of the Docs HyperCitizens

Clicking an NPC HyperCitizens

structureon npc click "<name>":HyperCitizens

Runs when a player right-clicks the NPC of that name

on npc click "Shopkeeper":
    execute player command "shop"
structureon npc left click "<name>":HyperCitizens

Runs when a player hits it

on npc left click "Guard":
    make npc "Guard" say "Hands off."
eventon npc click:HyperCitizens

Without a name: runs for every NPC

on npc click:
    log "%player.name% clicked %{_name}% (number %{_npc}%)"

What this event gives a script

In the blockWhat it is
{_npc}The NPC's number
{_name}Its name
Guide and examples
on npc click "Shopkeeper":
    execute player command "shop"

on npc click "Healer":
    cooldown: 30 seconds
    heal player
    make npc "Healer" say "There you go."

on npc left click "Guard":
    make npc "Guard" say "Hands off."

on npc click:
    log "%player.name% clicked %{_name}% (number %{_npc}%)"
SyntaxEffect
on npc click "<name>":Runs when a player right-clicks the NPC of that name
on npc left click "<name>":Runs when a player hits it
on npc click:Without a name: runs for every NPC
  • Inside the block, player is whoever clicked, as in HyperScript's own events. {_npc} is the NPC's number and {_name} its name.
  • The name is compared without colours and without regard to capitals, so "Guide" finds an NPC called &aGuide. If two NPCs share a name, the block runs for both.
  • A cooldown line works as on any event, per player.