dream_xd24

make me a skript where when you right click a item called "Sheild Bubble" which is a heart of the sea a bubble made out of blue glass with a radius of 8 spawns from where it is pressed.

Kodari AI
KodariMay 16 at 4:25 pm 6,766 (v2)

I’ll create a Skript that spawns a protective glass bubble when you right-click a Heart of the Sea item.

ShieldBubbleSkript
A defensive utility script that allows players to deploy protective glass bubbles. Right-clicking a Heart of the Sea named "Shield Bubble" creates a hollow sphere of blue stained glass with an 8-block radius. The bubble instantly forms around the activation point, providing temporary protection or visual barriers. Perfect for defensive gameplay mechanics or territory marking.

Created a Shield Bubble script that spawns an 8-block radius hollow sphere of light blue stained glass when you right-click a Heart of the Sea named “Shield Bubble”.

Installation:

  1. Place shield-bubble.sk in plugins/Skript/scripts/

  2. Run /sk reload shield-bubble or restart the server

  3. Use /givebubble to get the Shield Bubble item (requires shield.admin permission)

Features:

  • Hollow glass sphere (radius 8, configurable)

  • Only replaces air blocks (won’t destroy terrain)

  • Visual/sound effects on deployment

  • Item consumed on use (configurable)

  • /clearbubbles [radius] command to remove glass (requires shield.clear permission)

Configuration: Edit the options: section to customize radius, glass color, or whether the item is consumed.

Kodari can make mistakes. Review important code before using.
Files
shield-bubble.sk
Code
1 109
shield-bubble.sk
# Shield Bubble Skript
# Author: Generated
# Version: 1.0
# Description: Creates a blue glass bubble shield when right-clicking a special item

options:
    prefix: &b[Shield Bubble]&r
    item-name: &bShield Bubble
    radius: 8
    glass-type: light blue stained glass
    consume-item: true # Set to false if item should not be consumed

# Event to detect right-click with the Shield Bubble item
on right click:
    # Check if player is holding the correct item
    if player's tool is heart of the sea:
        if name of player's tool is "{@item-name}":
            # Get the center location (player's location)
            set {_center} to location of player
            
            # Visual feedback
            send "{@prefix} &7Deploying shield bubble..." to player
            play sound "block.beacon.activate" at {_center} with volume 1 and pitch 1.5
            
            # Create the sphere
            createBubble({_center}, {@radius})
            
            # Consume the item if enabled
            if {@consume-item} is true:
                remove 1 of player's tool from player's tool
                send "{@prefix} &7Shield bubble deployed!" to player
            else:
                send "{@prefix} &7Shield bubble deployed!" to player

# Function to create a hollow sphere of glass
function createBubble(center: location, radius: number):
    set {_rSquared} to {_radius} * {_radius}
    set {_innerRadius} to {_radius} - 1
    set {_innerSquared} to {_innerRadius} * {_innerRadius}
    
    # Loop through a cubic area
    loop all blocks in radius {_radius} around {_center}:
        set {_block} to loop-block
        
        # Calculate distance squared from center (more efficient than using distance)
        set {_dx} to x-coordinate of {_block} - x-coordinate of {_center}
        set {_dy} to y-coordinate of {_block} - y-coordinate of {_center}
        set {_dz} to z-coordinate of {_block} - z-coordinate of {_center}
        set {_distSquared} to ({_dx} * {_dx}) + ({_dy} * {_dy}) + ({_dz} * {_dz})
        
        # Check if block is on the sphere surface (hollow sphere)
        # Block is on surface if distance is between inner and outer radius
        if {_distSquared} <= {_rSquared}:
            if {_distSquared} >= {_innerSquared}:
                # Only replace air blocks (don't destroy existing blocks)
                if {_block} is air:
                    set {_block} to {@glass-type}
                    play effect "water_splash" at {_block} with count 3

# Admin command to give the Shield Bubble item
command /givebubble [<player>]:
    permission: shield.admin
    permission message: &cYou don't have permission to use this command!
    trigger:
        if arg-1 is set:
            set {_target} to arg-1
        else:
            if player is set:
                set {_target} to player
            else:
                send "{@prefix} &cYou must specify a player from console!"
                stop
        
        # Create the Shield Bubble item
        set {_item} to heart of the sea named "{@item-name}"
        set line 1 of lore of {_item} to "&7Right-click to deploy a"
        set line 2 of lore of {_item} to "&7protective glass bubble!"
        set line 3 of lore of {_item} to ""
        set line 4 of lore of {_item} to "&bRadius: &f{@radius} blocks"
        
        # Give item to player
        give {_item} to {_target}
        send "{@prefix} &7Shield Bubble item given to &b%{_target}%&7!" to sender
        send "{@prefix} &7You received a Shield Bubble item!" to {_target}

# Command to remove glass bubbles
command /clearbubbles [<number>]:
    permission: shield.clear
    permission message: &cYou don't have permission to use this command!
    trigger:
        if arg-1 is set:
            set {_radius} to arg-1
        else:
            set {_radius} to 20
        
        send "{@prefix} &7Removing glass within &b%{_radius}%&7 blocks..."
        set {_count} to 0
        
        loop all blocks in radius {_radius} around player:
            if loop-block is light blue stained glass:
                set loop-block to air
                add 1 to {_count}
        
        send "{@prefix} &7Removed &b%{_count}%&7 glass blocks!" to player

# Script load message
on script load:
    send "{@prefix} &aShield Bubble script loaded successfully!" to console
    send "{@prefix} &7Use /givebubble to obtain the item" to console