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. # In Verse, you often need to trigger the award manually # or use a device that awards points. # For this demo, we'll assume the trigger activation itself # awards points, but we need to ensure the thief is the one # receiving it. # Note: SetToAgentScore sets the *amount* to be awarded to the # *next activation*. We need to trigger that activation for the thief. # To keep it simple in Verse, we can use the ScoreManager's # activation to award the point to the 'agent' (thief). # However, SetToAgentScore specifically sets the score # *of the agent passed to it* to be the award amount # for the *next* activation of the ScoreManager. # Let's activate the ScoreManager for the thief. score_manager.Activate() # Connect the events. # When the button is pressed, run the theft function for the player who pressed it. button.Pressed.Bind(func(agent: agent): on_thief_action(agent) ) # Optional: Also trigger if they just walk into the zone. # trigger.Entered.Bind(func(agent: agent): # on_thief_action(agent) # )