Shoot projectile at target block skript

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

4cel

Member
Apr 18, 2025
3
0
1
When i reload my skript on my server, everything checks out and i do not know why it isn't working. here is the skript

It is supposed to document the player shooting the target blocks, once all four are shot, the fourth one opens a door by removing blocks, then 30 seconds later putting them back.

on projectile hit:
if event-projectile is arrow:
if type of event-block is target:
set {_loc1} to location -5532, 39, -1994
set {_loc2} to location -5525, 37, -1993
set {_loc3} to location -5531, 41, -2002
set {_loc4} to location -5521, 42, -2001
if event-block's location is {_loc1}:
set {hit_target_1::%shooter%} to true
if event-block's location is {_loc2}:
set {hit_target_2::%shooter%} to true
if event-block's location is {_loc3}:
set {hit_target_3::%shooter%} to true
if event-block's location is {_loc4}:
set {hit_target_4::%shooter%} to true
else if:
stop
if {hit_target_1::%shooter%} is true:
if {hit_target_2::%shooter%} is true:
if {hit_target_3::%shooter%} is true:
if {hit_target_4::%shooter%} is true:
set block at location -5537, 36, -1985 to air
set block at location -5537, 35, -1984 to air
wait 30 seconds
set block at location -5537, 36, -1985 to red_concrete
set block at location -5537, 35, -1984 to red_concrete
set {hit_target_1::%shooter%} to false
set {hit_target_2::%shooter%} to false
set {hit_target_3::%shooter%} to false
set {hit_target_4::%shooter%} to false

i am new to skript so any help would be greatly appreciated. The problems are:
- Any time a block is shot with an arrow, the door opens
- Even if i try to set the hit target things to false, they still immediately open the door on the first try.
This makes me think that 1. It is not recognising that i want the arrow to be shot specifically at a target block and 2. It does not require all four of the blocks to be shot??? please help!
 
this post doesn't show the indents in my code so i will send a screenshot(below this screenshot they are all on the same indent)
 

Attachments

  • 1744972051858.png
    1744972051858.png
    44.5 KB · Views: 21
Hey, try this:
Code:
on load:
    set {loc1} to location(-5532, 39, -1994, world "WORLD")
    set {loc2} to location(-5525, 37, -1993, world "WORLD")
    set {loc3} to location(-5531, 41, -2002, world "WORLD")
    set {loc4} to location(-5521, 42, -2001, world "WORLD")

on projectile hit:
    if event-projectile is arrow:
        if event-block is target:
            if event-block's location is {loc1}:
                set {hit_target_1::%shooter%} to true
            else if event-block's location is {loc2}:
                set {hit_target_2::%shooter%} to true
            else if event-block's location is {loc3}:
                set {hit_target_3::%shooter%} to true
            else if event-block's location is {loc4}:
                set {hit_target_4::%shooter%} to true
            if {hit_target_1::%shooter%}, {hit_target_2::%shooter%}, {hit_target_3::%shooter%} and {hit_target_4::%shooter%} is true:
                set block at location -5537, 36, -1985 to air
                set block at location -5537, 35, -1984 to air
                wait 30 seconds
                set block at location -5537, 36, -1985 to red concrete
                set block at location -5537, 35, -1984 to red concrete
                set {hit_target_1::%shooter%} to false
                set {hit_target_2::%shooter%} to false
                set {hit_target_3::%shooter%} to false
                set {hit_target_4::%shooter%} to false

#on right click:
    #send location of clicked block to player

Make sure your coords are right, if it wont work for you i added a commented part, just remove the "#" from it and click to the blocks that you need the coords of and change it.
 
Last edited:
i tried this in game and it seems to work, but only if all of the hit target things are already set to true.

command /targetset:
trigger:
set {_player} to player
set {hit_target_1::%{_player}%} to true
set {hit_target_2::%{_player}%} to true
set {hit_target_3::%{_player}%} to true
set {hit_target_4::%{_player}%} to true
send "&aDone, try it now!" to player

i created this command which sets them all to true, and if i use this and shoot a target, the door opens. When i use a command to set them all to false though, no matter how many times i shoot the targets, it won't open the door, probably meaning that the problem is that shooting the targets is not setting the hit target things to true.
 
Thats strange, it worked for me, make sure you have the coords right, because its really important