Solved Trap

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

Status
Not open for further replies.

BirdCanFly

Member
Jun 22, 2017
29
2
3
Hello, I want to make a command so the player will shoot a Oak Leave and when the Oak Leave hits the ground it will make a trap. But it doesn't work very well. Any one knows how to fix it?
code_language.skript:
command /trap:
    trigger:
        make the player shoot an item projectile of 1 oak leaves at speed 1.2
on item hit:
    if event-item is oak leaves:
        set {trap.location.%player%} to location of event-location
        loop blocks in radius 4 of {trap.location.%player%}:
            if loop-block is air:
                set loop-block to oak leaves
            loop blocks in radius 3 of {trap.location.%player%}:
            if loop-block is oak leaves:
                set loop-block to air
        wait 5 seconds
        loop blocks in radius 4 of {trap.location.%player%}:
        if loop-block is oak leaves:
            set loop-block to air
 
Have you done wrong formatting?

Because this is the right format code type:

code_language.skript:
on item hit:
    if event-item is oak leaves:
        set {trap.location.%player%} to location of event-location
        loop blocks in radius 4 of {trap.location.%player%}:
            if loop-block is air:
                set loop-block to oak leaves
            loop blocks in radius 3 of {trap.location.%player%}:
                if loop-block is oak leaves:
                    set loop-block to air
        wait 5 seconds
        loop blocks in radius 4 of {trap.location.%player%}:
            if loop-block is oak leaves:
                set loop-block to air
 
Fixed it, had to much Loops.
Thanks for the help.
 
Last edited by a moderator:
If you still want a more performant code:

code_language.skript:
command /trap:
    trigger:
        drop 1 oak leaves at location 1 blocks forwards and 2 blocks upwards player
        set {_trap} to last dropped item
        push {_trap} in direction of player at speed 0.8
        while ground state of {_trap} is false:
            wait 1 tick
        loop blocks in radius 4 of {_trap}:
            if loop-block is air:
                set loop-block to oak leaves
            loop blocks in radius 3 of {_trap}:
                if loop-block-2 is oak leaves:
                    set loop-block-2 to air
        wait 5 seconds
        loop blocks in radius 4 of {_trap}:
            if loop-block is oak leaves:
                set loop-block to air
 
Status
Not open for further replies.