Sound Barrier Break 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 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!

Subject_006

Member
Nov 20, 2025
1
0
1
Hi everyone,
I’m a bit out of practice with Skript (it’s been years since I last wrote anything), and I’m trying to create a Skript that simulates a player breaking the sound barrier.

Here’s what I’m trying to achieve:

  • When a player reaches 50 blocks per second, they should trigger a “sonic boom.”
  • Every player within a 400-block radius should hear an explosion sound at the same volume.
  • The speeding player should also have a shockwave ring effect that follows them for 5 seconds.
  • There should be at least a 60-second cooldown between sonic booms per player.

My problem is that every time I fix one error, two more pop up. I can’t seem to get it right. If anyone could help point out what I’m doing wrong or provide a working skript, I’d really appreciate it. <3




Code:
# ============================================
#   Sonic Boom / Sound Barrier Skript
#   Fixed version - avoids dynamic-brace issues & trig errors
#   Requires: Skript 2.7+, SkBee (1.21+)
# ============================================

options:
    speed-threshold: 50             # blocks/sec required
    sound-cooldown: 60 seconds      # how often a player can trigger the boom
    shockwave-duration: 5 seconds   # how long the particle effect lasts
    sound-radius: 400
    pitch: 0.8

# Precomputed 12-point unit circle offsets (radius 1)
# index 1..12
on skript load:
    set {_xs::*} to 1, 0.866, 0.5, 0, -0.5, -0.866, -1, -0.866, -0.5, 0, 0.5, 0.866
    set {_zs::*} to 0, 0.5, 0.866, 1, 0.866, 0.5, 0, -0.5, -0.866, -1, -0.866, -0.5
    broadcast "&a[Skript] Sound-Barrier script loaded and offsets initialized."

# Track last locations per player (use player as key, avoids nested braces)
every tick:
    loop all players:
        set {_current} to loop-player's location
        set {_previous} to {sb_lastloc.%loop-player%}
        set {sb_lastloc.%loop-player%} to {_current}

        if {_previous} is not set:
            continue

        # distance moved this tick (1 tick = 1/20 sec)
        set {_dist} to distance between {_previous} and {_current}

        # ignore teleports / unnatural movement (>10 blocks/tick)
        if {_dist} > 10:
            continue

        # convert to blocks/sec
        set {_speed} to {_dist} * 20

        # check threshold
        if {_speed} >= {@speed-threshold}:
            # cooldown check
            if {sb_cooldown.%loop-player%} is set:
                if difference between now and {sb_cooldown.%loop-player%} < {@sound-cooldown}:
                    continue

            # set cooldown timestamp
            set {sb_cooldown.%loop-player%} to now

            # Play sonic boom to nearby players (uniform volume/pitch)
            loop all players:
                if distance between loop-player and {_current} <= {@sound-radius}:
                    play sound "entity.generic.explode" with volume 10 and pitch {@pitch} at {_current} for loop-player

            # Start shockwave trail effect on the player for the configured duration
            # We increment radius each tick for an expanding effect
            set {_totalTicks} to {@shockwave-duration} * 20
            set {_r} to 0.6                      # starting radius
            set {_rstep} to 0.08                 # how much radius grows each tick

            loop {_totalTicks} times:
                # center follows player's current location
                set {_loc} to loop-player's location
                # height of ring relative to player (tweak if you want rings lower/higher)
                set {_yoff} to 0.5

                # spawn particles at 12 offsets multiplied by current radius
                loop 12 times:
                    set {_i} to loop-number
                    set {_xoff} to {_xs::%{_i}%} * {_r}
                    set {_zoff} to {_zs::%{_i}%} * {_r}

                    # construct particle point
                    set {_point} to {_loc}
                    set x-coordinate of {_point} to x-coordinate of {_loc} + {_xoff}
                    set y-coordinate of {_point} to y-coordinate of {_loc} + {_yoff}
                    set z-coordinate of {_point} to z-coordinate of {_loc} + {_zoff}

                    # spawn a single crit_magic particle at that point
                    skbee particle "crit_magic" at {_point} offset 0,0,0 speed 0 count 1

                # optionally spawn a faint inner ring (more depth) - comment out if too heavy
                loop 6 times:
                    set {_j} to loop-number * 2
                    set {_xoff2} to {_xs::%{_j}%} * ({_r} * 0.6)
                    set {_zoff2} to {_zs::%{_j}%} * ({_r} * 0.6)
                    set {_point2} to {_loc}
                    set x-coordinate of {_point2} to x-coordinate of {_loc} + {_xoff2}
                    set y-coordinate of {_point2} to y-coordinate of {_loc} + {_yoff}
                    set z-coordinate of {_point2} to z-coordinate of {_loc} + {_zoff2}
                    skbee particle "crit_magic" at {_point2} offset 0,0,0 speed 0 count 1

                wait 1 tick
                add {_rstep} to {_r}   # expand radius gradually
 

Attachments

  • Sound Barrier.sk
    4.3 KB · Views: 58