# This is our main script. # It runs when the island starts. # We use a creative_device class to hold our devices and assets. treasure_sound_device := class(creative_device): # We reference the trigger_device placed in UEFN. # Drag your TreasureZone trigger device here in the details panel. @editable TreasureZone : trigger_device = trigger_device{} # We reference the audio_player_device placed in UEFN. # Drag your Audio Player device here in the details panel. # The Audio Player device has a sound asset assigned to it. @editable TreasureAudio : audio_player_device = audio_player_device{} # OnBegin runs once when the island starts. # It is like turning on the lights. OnBegin() : void = # Tell the console the script is ready. Print("Sound system ready!") # Connect to the TriggeredEvent on the trigger device. # This runs our function when a player enters the zone. TreasureZone.TriggeredEvent.Subscribe(OnZoneEntered) # This function runs every time a player enters the zone. # 'Agent' is the player who walked in. OnZoneEntered(Agent : ?agent) : void = # Play the sound through the audio player device. TreasureAudio.Play() Print("Ding! You found treasure!")