Solved Need help specifying a projectile and have it retain its particle trail

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

Status
Not open for further replies.

GTR

New Member
Sep 9, 2022
3
1
3
26
Hey I'm having an issue with my little project here. When a player right clicks a red candle, it launches a snowball with a smoke trail that will explode on impact. The explosion part works fine; however, when multiple snowballs are shot, after the first one explodes all the remaining snowballs lose their particle trails.

Also is there a way to only have the snowball that's spawned from the script have these properties? At the moment every snowball executes this.

Code:
# Dynamite Throwing Action

on leftclick holding red candle:
    if name of event-item is "&cDynamite":
        make the player shoot a snowball at speed 1
        play sound "entity.tnt.primed" with volume 3 and pitch 2
    
    if player's gamemode is creative:
        stop
    
    else:
        remove 1 red candle named "&cDynamite" from player's inventory

# Projectile Trail

on shoot:
    projectile is a snowball
    set {p-s-dtrail.%shooter%} to 1
    loop 1000 times:
        if {p-s-dtrail.%shooter%} is 1:
            wait 1 tick
            play smoke particle at location of projectile

# Explosion Event

on projectile hit:
    projectile is a snowball
    create an explosion of force 1.8 at the projectile
    set {p-s-dtrail.%shooter%} to 0

I'm very new to skript, so apologies if this is a very simple fix. Thanks!
 
Use metadata of entity instead variable, because your's variable linked to player, not projectile
https://docs.skriptlang.org/expressions.html#ExprMetadata
I've switched to metadata and have fixed every snowball causing an explosion, but I can't seem to get the loop of particles for its trail to work.
Code:
# Dynamite Throwing Action

on leftclick holding red candle:
    if name of item is "&cDynamite":
        cancel event
        make the player shoot a snowball at speed 1
        set metadata "FuseTrail" of shot projectile to true
        play sound "entity.tnt.primed" with volume 3 and pitch 2
     
    if player's gamemode is creative:
        stop
 
    else:
        remove 1 red candle from player's tool
     
# Projectile Trail

on shoot:
    projectile is a snowball
    loop 1000 times:
        if metadata "FuseTrail" of projectile is true:
            wait 1 tick
            play smoke particle at location of projectile

# Explosion Event

on projectile hit:
    if metadata "FuseTrail" of projectile is true:
        create an explosion of force 1.8 at the projectile
        play 10 cloud with speed 0.05 at location
I've also gotten Skellet if that matters.
 
Last edited:
Code:
on leftclick holding red candle:
    cancel event
    make the player shoot a snowball at speed 1
    set {_projectile} to shot projectile
    set metadata "FuseTrail" of {_projectile} to true
    play sound "entity.tnt.primed" with volume 3 and pitch 2
    if player's gamemode is not creative:
        remove 1 red candle from player's tool

    while {_projectile} is not dead:
        wait 1 tick
        play smoke particle at {_projectile}

 
# Explosion Event
on projectile hit:
    if metadata "FuseTrail" of projectile is true:
        create an explosion of force 1.8 at the projectile
        play 10 cloud with speed 0.05 at location
 
Code:
on leftclick holding red candle:
    cancel event
    make the player shoot a snowball at speed 1
    set {_projectile} to shot projectile
    set metadata "FuseTrail" of {_projectile} to true
    play sound "entity.tnt.primed" with volume 3 and pitch 2
    if player's gamemode is not creative:
        remove 1 red candle from player's tool

    while {_projectile} is not dead:
        wait 1 tick
        play smoke particle at {_projectile}

 
# Explosion Event
on projectile hit:
    if metadata "FuseTrail" of projectile is true:
        create an explosion of force 1.8 at the projectile
        play 10 cloud with speed 0.05 at location
Works perfectly, thank you!
 
  • Like
Reactions: lotzy
Status
Not open for further replies.