Solved Knockback Problem (not working)

  • 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.
D

Deleted member 6377

Using Skript on 1.8.9 with no add-ons. Would like to keep it this way.

code_language.skript:
on leftclick:
    if player’s target is a player;
        if {reach.%player%} is true:
            set {_loc} to location of player’s target
            set {_dis} to distance between player and {_loc}
            if {_dis} > 3:
                damage player’s target by 1
                push player’s target upwards with force 0.5
^^^
This is a bit simpler version of the code since I’m trying to recall it all from memory (I’m using my phone atm)

No errors.


Problem:

The damage part works, but it doesn’t push the target.
 
code_language.skript:
on damage of player:
    if {reach.%attacker%} is true:
        if distance between attacker and victim > 3:
            damage attacker by 1
            push attacker upwards with force 0.5
 
code_language.skript:
on damage of player:
    if {reach.%attacker%} is true:
        if distance between attacker and victim > 3:
            damage attacker by 1
            push attacker upwards with force 0.5
That would only work if the victim was already attacked...
 
That would only work if the victim was already attacked...
On damage is called when the victim is damaged (also when another plugin / minecraft cancels it)
 
try this, I dont have a player on my test server to test with, so i tested with my trusty sheep, and it works
code_language.skript:
on leftclick:
    if target is a player:
        if {reach.%player%} is true:
            set {_loc} to location of target
            set {_dis} to distance between player and {_loc}
            if {_dis} > 3:
                damage target by 1
                push target upwards with force 0.5
 
try this, I dont have a player on my test server to test with, so i tested with my trusty sheep, and it works
code_language.skript:
on leftclick:
    if target is a player:
        if {reach.%player%} is true:
            set {_loc} to location of target
            set {_dis} to distance between player and {_loc}
            if {_dis} > 3:
                damage target by 1
                push target upwards with force 0.5
Also, there's "if target is a player" so it shouldn't work with a sheep.

Still, not working.

EDIT #1:

I was going to test it with a Zombie, and when I removed "if target is a player" it worked. Strange ;/

anyway thx lol

EDIT #2:

yeah, it was working, and then all the sudden it stopped working.

it still damages the player, but the knockback is only working for mobs now

EDIT #3:

it started working again, after a zombie attacked my alt. really strange bug

EDIT #4:

and it stopped working again after i went in creative and back.

EDIT #5: (idk why im editing so much lol)

found out the culprit. pretty sure it's /tpall. after i let the zombies attack me and my alt, the knockback worked. i went in gmc and tried it, still worked. i did /tpall, and it stopped working

EDIT #6:

actually, i found the actual culprit. when i hit the player from under 3 blocks, it stops the knockback even after i go 3 or more blocks away

EDIT #7:

the zombie tactic stopped working, still not dealing knockback to players
 
Last edited by a moderator:
Also, there's "if target is a player" so it shouldn't work with a sheep.

Still, not working.

EDIT #1:

I was going to test it with a Zombie, and when I removed "if target is a player" it worked. Strange ;/

anyway thx lol

EDIT #2:

yeah, it was working, and then all the sudden it stopped working.

it still damages the player, but the knockback is only working for mobs now

EDIT #3:

it started working again, after a zombie attacked my alt. really strange bug

EDIT #4:

and it stopped working again after i went in creative and back.

EDIT #5: (idk why im editing so much lol)

found out the culprit. pretty sure it's /tpall. after i let the zombies attack me and my alt, the knockback worked. i went in gmc and tried it, still worked. i did /tpall, and it stopped working

EDIT #6:

actually, i found the actual culprit. when i hit the player from under 3 blocks, it stops the knockback even after i go 3 or more blocks away

EDIT #7:

the zombie tactic stopped working, still not dealing knockback to players
That's a lot of edits
[doublepost=1531894578,1531894390][/doublepost]But for the thread, try parsing the target (if it's a player) as an entity or player. Also try broadcasting the target, for debugging purposes
 
code_language.skript:
on damage of player:
    if {reach.%attacker%} is true:
        if distance between attacker and victim > 3:
            damage attacker by 1
            push attacker upwards with force 0.5
Actually, this would work. Thanks for the help lol
 
Status
Not open for further replies.