using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script. # It manages a Trigger Device and a Speaker Device placed in the world. dj_booth := class(creative_device): # Drag your Audio Player Device into this property slot in the UEFN editor. @editable Speaker : audio_player_device = audio_player_device{} # Drag your Trigger Device into this property slot in the UEFN editor. @editable Trigger : trigger_device = trigger_device{} # We create a variable to track whether the music is currently playing. # var means its value can change — this is our "light switch." var MusicPlaying : logic = false # OnBegin runs once when the island starts. We wire up our events here. OnBegin() : void = # Subscribe to the trigger's triggered event. # These act as our tripwires. Trigger.TriggeredEvent.Subscribe(OnPlayerEnter) # This event happens when a player triggers the Trigger Device. # It is like a tripwire. OnPlayerEnter(MaybeAgent : ?agent) : void = # Only start the music if it is not already playing. if (MusicPlaying = false): # This line plays the music! # We tell the speaker to start playing. Speaker.Play() set MusicPlaying = true Print("The beat is dropping!") else: # Only stop the music if it is currently playing. # This line stops the music. Speaker.Stop() set MusicPlaying = false Print("The concert is over.")