Health certain amount of health on right click with item.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

kittkarrkitt

Supporter
Jan 4, 2021
33
0
6
Hi, I need to know how to give a player (any amount) of hearts when they right click with a specificly named item in their hands, for example a medkit. /heal would be good, but I dont want it to heal all health, but just (any amount) of hearts and without the healing effect that /heal has like taking away potion effects. It just needs to give me (any amount) of hearts on right click.

Here is my code:

Code:
command /medkit:
    trigger:
        give diamond named "&4Medkit" with lore "&cHeal 5 hearts" to the player
        message "&fYou have received a &4Medkit&f!"

on right click:
    if player is holding an diamond named "&4Medkit" with lore "&cHeal 5 hearts":
        broadcast "&4%player% &cused a medkit!"

Skript info:
upload_2021-1-16_19-24-58.png
 
Code:
command /medkit:
  trigger:
    set {med} to difference between {med.%player%} and now
    if {med} is less than 30 seconds:
      send "&cYou cannot use the Medkit for another %difference between {med} and 30 seconds%&c."
      stop
    set {med.%player%} to now
    give diamond named "&4Medkit" with lore "&cHeal 5 hearts" to the player
    message "&fYou have received a &4Medkit&f!"
 
on right click:
  player is holding a diamond named "&4Medkit" with lore "&cHeal 5 hearts":
    if player's health is 10:
      send "&cYou're already full health!"
    else:
      remove 1 of player's held item from player's inventory
      broadcast "&4%player% &cused a medkit!"
      heal player by 5 hearts

It's been tested. Also, I added a command cooldown and a feature that you cannot use the medkit if you're full health and I made it actually heal the player by 5 hearts. I also added it so if you have 2 med kits it will take one of them (only if u use them).
Have fun & happy coding
 
Status
Not open for further replies.