When Treasure Obtained
Fires when a player claims the reward of a Treasure Chest, the moment the chest opens and the prize is collected.
Introduction
When Treasure Obtained is an event in the Treasure Chest group of World Events. It fires when a player claims the reward of a Treasure Chest - the moment the chest opens and the prize is collected. When it fires, the event hands one value to your script: Player , the player who took the treasure. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. Treasure hunting usually starts long before the chest opens: When Trigger Entered can detect a player approaching the chest, and a countdown from When Timer Times Out adds pressure to the hunt. The reward itself often spawns through When Prop is Added , and if the prize is a weapon, hand it over with the setup described in the Weapon guide. When Treasure Obtained event block in the Script Editor with the Player parameter Image The When Treasure Obtained event in the Script Editor. caption
Parameters
Player the player who claimed the treasure Parameter Description
How to Access
How to Access - Event When Treasure Obtained
How to Use
Select the object, press Propertie (the blue equalizer icon) in the bottom action menu, and scroll to the bottom of the properties panel. Press Add Component and pick the Treasure Chest component; its block stacks below the existing properties with the When Treasure Obtained event inside it. Press the + button below the event to add a script, then press Edit on that script to open the script editor and build the actions that should run when the event fires. Press Play and open the treasure chest, then check that the actions run.
Example
When Treasure Obtained: Execute Player.Inventory.Add Item Item Quantity 1 when-treasure-obtained-example.png Adds the chest reward item to the claiming player's inventory when the chest opens. caption
Common Uses
Move the claimed reward from the bag into the toolbar, since the chest only drops it into the bag automatically Show a personal message or effect only for the player who claimed the chest Count rare chest claims toward a quest or achievement
Tip
The chest is claimable once on the server, so every player who interacts after the first claim gets nothing. Place several chests with the same reward if the moment should be repeatable for more players.