Need help with Keep potion effect on death of a player.

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

BettingCamp

Member
Oct 20, 2023
10
1
3
on death of a player:
set {_playerEffects::*} to all potion effects of the victim
remove all potion effects from the victim
wait 1 tick
add all {_playerEffects::*} to the victim

on respawn of a player:
if {_playerEffects::*} is set:
add all {_playerEffects::*} to the player


Why this is not working i am in 1.17 with Skript 2.7.1 with SkBee 1.15.3
 
There’s possibly a few solutions as i’m not completely sure what your goal is here

#1 cancel the death event and just teleport the player to spawn (This would make the potion effects not remove and you wouldn’t have to do any of this code)

#2 Try adding “wait 1 tick” right after the “on respawn of a player”

#3 Why are you removing the potion effects if you want to add them again??
 
try this
Code:
on death of a player:
    set {_playerEffects::%victim%::*} to all potion effects of the victim

on respawn:
    if {_playerEffects::%player%::*} is set:
        add {_playerEffects::%player%::*} to the player
 
Hey, you can try this:

Code:
on death:
    loop all active potion effects of victim:
        delete {potions.%victim%::*}
        add loop-value to {potions.%victim%::*}

on respawn:
    loop {potions.%player%::*}:
        wait 1 tick
        apply loop-value to player
 
Code:
Code:
on death:
    loop all active potion effects of victim:
        delete {potions.%victim%::*}
        add loop-value to {potions.%victim%::*}

on respawn:
    loop {potions.%player%::*}:
        wait 1 tick
        apply loop-value to player
Thanks it worked
 
  • Like
Reactions: DanRub
Hey, you can try this:

Code:
on death:
    loop all active potion effects of victim:
        delete {potions.%victim%::*}
        add loop-value to {potions.%victim%::*}

on respawn:
    loop {potions.%player%::*}:
        wait 1 tick
        apply loop-value to player
Hey this is not working properly it gives player the effects everytime when player dies even if the player don't have effects before death
 
hm, try this:
Code:
on death:
    loop all active potion effects of victim:
        clear {potions::%victim%::*}
        add loop-value to {potions::%victim%::*}


on respawn:
    loop {potions::%player%::*}:
        wait 1 tick
        apply loop-value to player
        clear {potions::%player%::*}