Need help with Defenses for an rpg server

  • 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 community!

    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!

By_Mango

Member
Jul 29, 2024
2
0
1
Code:
on right click:
    if player is holding feather named "&6Dodge":
        broadcast "1"
        set {_Dodge.%uuid of player%} to true
        subtract 1 feather named "&6Dodge" from player
    
on damage:
        if {_Dodge.%uuid of victim%} is true:
                heal victim by victim's last damage
                wait 1 tick
                set {_Dodge.%uuid of victim%} to false

I've tried tons of things but the code wont heal the victim and doesn't acknowledge that the victim has dodge on.
 
This answer has been divided into 2 parts, because only half-way through writing the second part did I realize the primary issue with your script.

#1
Any variable that starts with an underscore (i.e. _) is called a local variable. It can only be used in the section in which it was declared, hence the name. Section essentially refers to your events, commands, etc. Take for instance the code provided below. As {_x} is a local variable declared in the command /test section, it will not be visible to other sections. Thus, when we execute the /peek command after executing /test, we will not see an output, as command /peek cannot access that variable.
AppleScript:
command /test:
    trigger:
        set {_x} to 5

command /peek:
    trigger:
        send {_x} to player


#2
You're healing them before they're actually damaged. If you didn't know, you can actually modify the amount of damage that was dealt in the event itself. For instance, if you don't want the victim to be damaged at all, you can set the damage to 0.

Alternatively, you can just cancel the event in this case, which is what I would do. I suppose you wouldn't want to do this if you still want the damage indicator to go off, which I don't think is the intended effect.