Verse Library verse

01 Fragment

Allows a player to steal points from a target player via trigger or button activation.

verse-library/settoagentscore/01-fragment.verse

using { /Fortnite.com/Devices }

# This is our "Thief Trap" script.
# It lives on a Trigger Volume.

trigger: TriggerVolume = script.GetTriggerVolume()
button: Button = script.GetButton("Button")
score_manager: ScoreManager = script.GetScoreManager()

# We need to know who the victim is. 
# For simplicity, let's say the victim is the player 
# who spawned in last, or we can hardcode an index.
# Here, we'll use a variable to store the victim's Agent.
# In a real game, you'd pick this dynamically.
victim_agent: agent = script.GetPlayerAgent(0) # Player 1 is our victim

# This function runs when the trigger is entered or button is pressed.
# 'agent' here is the PLAYER (the thief) who triggered it.
on_thief_action := func(agent: agent):
    # Step 1: Get the victim's current score.
    # We use GetAgentScore to see how much loot the victim has.
    victim_score: int = score_manager.GetAgentScore(victim_agent)
    
    # Step 2: Set the award for the NEXT action.
    # This is the magic line. We tell the Score Manager:
    # "When the thief does something, give them 'victim_score' points."
    score_manager.SetToAgentScore(victim_agent)
    
    # Step 3: Actually give the points to the thief.
    # We do this by "activating" the score manager for the thief.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in