How to make a health and shield changer and after elimination player, hp is been saved!

Hello. Please help me. I want to do hp changer (triggers which change health and shield) on programming language Verse. I want he change hp for all players on my map and after player elimination hp’s been is saved. Thank you in advance!

Hello FedorOrehshek! I will try to help you with this!

First of all, don’t forget to add “using { /Fortnite.com/Characters }” in your device. This will allow you to use some character functions.

Then, you will need to set the Max Health and Max Shield for the player that activates the trigger using SetMaxHealth and SetMaxShield functions on the FortniteCharacter. To do that you will need to use a code similar to this:

#Variables to set the values
@editable
MoreHP : float = 50.0
@editable
MoreShield : float = 50.0
@editable
Trigger : trigger_device = trigger_device{}

OnBegin<override>()<suspends>:void=

    Trigger.TriggeredEvent.Subscribe(OnTrigger) #Subscribe to Trigger and call the corresponding function

#Function to trigger the HP and Shield change
OnTrigger (MaybeAgent:?agent) : void = #Check if the agent exists
    if (Agent := MaybeAgent?): #Get the agent that interacts with the trigger
        if (Player := Agent.GetFortCharacter[]): #Get the actual Fortnite Character and set it as Player
            CurrentHP := Player.GetMaxHealth() #Create local variable for current HP
            CurrentShield := Player.GetMaxShield() #Create local variable for current Shield
            Player.SetMaxHealth(CurrentHP + MoreHP) #Change player's HP based on CurrentHP
            Player.SetMaxShield(CurrentShield + MoreShield) #Change player's Shield based on CurrentShield

Additionaly you should save the new values after increasing it, so you can assign those values again after a playe respawns. That’s because when a player dies, their stats are reset to the ones defined on the Island Settings.

Hope it helps you!

How to save new values?

Hey FedorOrehshek! It’s a pleasure!

To store those values I recommend to use Maps. Here you can se the documentation.

You will probably need to create 2 different Maps, one for the HP and another for the Shield.

Each time a player picks up a buff, you save their current HP/Shield on the corresponding Map and when they respawn you assign the values from the Map to the player using the functions mentioned on my previous answer.

Thank you!

1 Like

Hello. Can you please help and show me exactly how to do this?