Is there a way to keep potion effects when you die?

Is there a way for a specific player to keep the potion effect when he dies? For example, my friend and i are playing, with both a different potion effect. But when i die, i have to get that potion effect back, and my friend not.

A fast clock that constantly checks if a player is dead, and if so gives that player the potion effect, wouldn't work because then my friend would also get the same potion effect as I do.


Solution 1:

The simplest way you can do this is have a fast clock, but don't check if there is a player that has died. Instead, just put your Minecraft username there and it will keep giving you the potion effect even after you die. E.g. (gives jump boost 2 to player with name 'username'):

/effect username minecraft:jump_boost 99999 2

Alternatively, if you want this to work with any two people, have a scoreboard objective and set it to 1 for the player to receive the potion effect. Then give the player with a score of 1 for that objective the potion effect with a really fast clock.

/effect @a[score_effect_min=1] minecraft:jump_boost 99999 2

Hope this helped you!