on rightclick on entity: if event-entity is villager: if name of event-entity is not "Aptekarz": stop send "&7Aptekarz: &8Witam pana" open chest with 1 rows named "Aptekarz" to player wait 3 tick format slot 4 of player with 1 of iron ingot with name "&cLeki" with lore "&7Cena zakupu: &a50 &2Monet" to run [buyPills(player)] function buyPills(player: player): close {_player}'s inventory if {_player}'s ballance >= 50: remove 50 from {_player}'s ballance give 1 iron ingot with name "&cLeki" to {_player} send "&8Aptekarz&7 Prosze , oto twoje leki!" to {_player} else: send "&8Aptekarz:&7 Przepraszam , lecz nie posiadasz wymaganej ilosci monet!" to {_player}