How can I change the maximum health of the player?(using verse)

Hello!
I want to ask how can I change the maximum health of the player.
For example , if you pay 100 coin your health changes 100 to 120.

You can use fort_character.SetMaxHealth(:float) for that, you’d need to retrieve the fort_character of the player before of course

You can use .SetMaxHealth() to change the max health of a player. Here is an example:

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }

# A Verse-authored creative device that can be placed in a level
Test := class(creative_device):
    # I used button in this example. But any device that accept 'agent' can be used
    @editable Button: button_device = button_device{}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        # When interacting with the button, your max health will be set to 150
        Button.InteractedWithEvent.Subscribe(OnInteracted)

    # Set max health of the instigator to 150 
    OnInteracted(Agent: agent): void=
        if (FortChar:= Agent.GetFortCharacter[]):
            FortChar.SetMaxHealth(150.0) # Or any other value. It must be float!

Hello

You have access to the health of players via the fort_character

# Get the player list
AllPlayers := GetPlayspace().GetPlayers()

# Find the actual player
if (FortPlayer := AllPlayers[0].GetFortCharacter[]):
    Print("Player has {FortPlayer.GetMaxHealth()} HP")

    # Get the current total health of the player and increase it by 100
    Health : float = FortPlayer.GetMaxHealth() + 100.0
    FortPlayer.SetMaxHealth(Health)

    Print("New HP set to {FortPlayer.GetMaxHealth()}")

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.