_iiroma

make me a skript that make if a crossbow named mingun it shoot like a gun

Kodari AI
KodariJun 2 at 11:12 am 6
MinigunCrossbow
A Skript that turns any crossbow named "minigun" into a rapid-fire weapon. When a player shoots a crossbow named "minigun", it automatically fires multiple arrows in quick succession, simulating a machine gun effect. Includes visual and sound effects for immersion, configurable fire rate, and a cooldown system to prevent spam abuse.

How it works:

Feature
Detail
Trigger
Any crossbow with
minigun
in its name
Burst
Fires
8 arrows
in rapid succession
Spread
Random bullet spread for realism
Cooldown
1.5 seconds
between bursts
Sounds
Alternating pitch gunshot sounds
Particles
Muzzle smoke on each shot

Setup:

  1. Drop minigun_crossbow.sk into plugins/Skript/scripts/

  2. Run /sk reload minigun_crossbow

  3. Run /minigun (requires minigun.give permission) to get the weapon

  4. Load it by right-clicking, then fire away!

⚙️ Tweak burst-count, burst-delay, spread, and cooldown in the options block at the top to balance the gun to your liking.

_iiroma

[11:14:46 INFO]: [Skript] Reloading crossbow.sk... [11:14:46 INFO]: Line 49: (crossbow.sk) [11:14:46 INFO]:

Can't understand this expression: 'charged crossbow named "\&6\&lMinigun"' [11:14:46 INFO]:

Line: give charged crossbow named "{@minigun-name}" to {_target} [11:14:46 INFO]: [11:14:46 INFO]: Line 14: (crossbow.sk) [11:14:46 INFO]:

Can't compare a slot with 'charged' [11:14:46 INFO]:

Line: if player's tool is charged: [11:14:46 INFO]: [11:14:46 INFO]: [Minigun] Minigun Crossbow script loaded successfully! [11:14:46 INFO]: - Right-click with a crossbow named 'Minigun' to fire [11:14:46 INFO]: - Use /minigun to get one [11:14:46 INFO]:

Encountered 2 errors while reloading crossbow.sk! (19m

Kodari AI
KodariJun 2 at 11:16 am 5

Let me see the current script to fix both errors.

Two fixes needed:

  1. give crossbow named ... instead of charged crossbow (Skript can’t give charged items that way)

  2. Remove the if player's tool is charged: check (that was in the old version — not in this file, so the error must be from a different file on your server)

The script also has a logic conflict: two on shoot: events both catch the same arrow — one fires the burst, the other cancels the event, so nothing shoots. I’ll fix all of this now.

Key fixes:

  • ✅ Removed charged crossbow from the give command — just gives a regular crossbow named Minigun (player loads it manually by right-clicking like normal)

  • ✅ Merged both on shoot: events into one — the cancel now happens inside the minigun check, so normal crossbows are unaffected and the burst actually fires

  • ✅ Used loop-number instead of a manual {_count} variable

Kodari can make mistakes. Review important code before using.
Files
minigun_crossbow.sk
Code
1 88
minigun_crossbow.sk
# ================================
# Minigun Crossbow
# ================================
# Place in: plugins/Skript/scripts/
# Reload with: /sk reload minigun_crossbow
# ================================

options:
    # Name the crossbow must have (case-insensitive check)
    gun-name: &fMinigun
    # How many extra arrows to fire per burst
    burst-count: 8
    # Delay between each burst arrow (in ticks, 2 ticks = 0.1s)
    burst-delay: 2
    # Spread of the bullets (higher = more spread)
    spread: 0.25
    # Bullet speed
    speed: 3.0
    # Cooldown between bursts (in seconds)
    cooldown: 1.5

# ================================
# When a player shoots a crossbow
# ================================
on shoot:
    shooter is a player
    projectile is an arrow

    set {_item} to player's tool
    if type of {_item} is crossbow:
        if display name of {_item} contains "minigun":

            # Cancel the original single arrow shot
            cancel event

            # Prevent firing if on cooldown
            if {minigun.cooldown::%player's uuid%} is set:
                send action bar "&cMinigun cooling down!" to player
                stop

            # Set cooldown immediately so burst can't be re-triggered mid-fire
            set {minigun.cooldown::%player's uuid%} to true

            # Burst fire loop
            set {_player} to player
            loop {@burst-count} times:
                set {_count} to loop-number
                wait {_count} * {@burst-delay} ticks

                if {_player} is online:
                    # Spawn arrow from player's eyes
                    set {_loc} to eye location of {_player}
                    set {_arrow} to shoot arrow from {_loc} at speed {@speed}
                    set shooter of {_arrow} to {_player}

                    # Apply random spread to velocity
                    set {_spreadX} to (random number between -{@spread} and {@spread})
                    set {_spreadY} to (random number between -{@spread} and {@spread})
                    set {_vx} to x-velocity of {_arrow} + {_spreadX}
                    set {_vy} to y-velocity of {_arrow} + {_spreadY}
                    set {_vz} to z-velocity of {_arrow}
                    set velocity of {_arrow} to vector({_vx}, {_vy}, {_vz})

                    # Muzzle smoke
                    play smoke particle at eye location of {_player} offset by 0, 0, 0 with speed 0.05 count 3

                    # Rapid-fire gunshot sounds
                    if loop-number mod 2 is 0:
                        play sound "entity.arrow.shoot" at {_player} with volume 0.6 and pitch 1.8
                    else:
                        play sound "entity.arrow.shoot" at {_player} with volume 0.6 and pitch 1.6

            # Clear cooldown after delay
            wait {@cooldown} seconds
            delete {minigun.cooldown::%player's uuid%}

# ================================
# Give command
# ================================
command /minigun:
    permission: minigun.give
    permission message: &cYou don't have permission to use this!
    trigger:
        give player 1 crossbow named "{@gun-name}"
        send "&aYou received a &fMinigun&a! Load it by right-clicking, then fire!"

on script load:
    send "[Minigun] Minigun Crossbow loaded!" to console