# This script lives on the Island. It finds our devices and listens for triggers. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } MoodSwitcher_Script := class(creative_device): # 1. Define the devices we want to control. # Think of these as "handles" to the devices in your level. # Decorate with @editable so they appear as linkable fields in the UEFN Details panel. @editable Instrument_Player : instrument_player_device = instrument_player_device{} @editable Trigger : trigger_device = trigger_device{} # 2. This function runs when the game starts. # It's like the "Game Start" event in the device menu, but with more power. OnBegin() : void = # 3. Listen for the trigger being activated. # When the player hits the trigger, this code runs. Trigger.TriggeredEvent.Subscribe(OnTriggered) # 4. This function is called whenever the Trigger fires. OnTriggered(Agent : agent) : void = # 5. Change the instrument! # PlayInstrument tells the Instrument Player device to activate. # Instrument selection is configured in the device's Details panel in the editor; # use the device's Play function to start it from Verse. # note: instrument_player_device exposes Play/Stop but not a runtime string-based # SetInstrument API; swap the active instrument by configuring the device property # in the UEFN Details panel and calling Play here. Instrument_Player.Play() # Optional: Print a message to the output log so you know it happened. Print("Mood switched — Instrument Player triggered!")