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<override>()<suspends> : 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.
Verse Library
verse
01 Device
Plays background music when players enter a trigger zone, using a state flag to prevent loops.
verse-library/build-your-own-lego-music-concert-in-fortnite-creative/01-device.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.