# This is the main script for our beat box island. # It controls the music player. using { /Fortnite.com/Devices } using { /Fortnite.com/Devices/Patchwork } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a new type called BeatBox. # This is like a blueprint for our island logic. BeatBox := class(creative_device): # This is a variable for our music device. # It holds the Patchwork Music Player. # Drag your Patchwork Music Player device onto this property # in the UEFN Details panel after uploading the script. @editable MusicPlayer : speaker_device = speaker_device{} # This is a variable for the stop trigger device. # It listens for a player stepping on it to stop the music. # Drag a Trigger device (your "StopWall") onto this property # in the UEFN Details panel. @editable StopTrigger : trigger_device = trigger_device{} # This function runs when the game starts. OnBegin(): void = # We subscribe to the StopTrigger's TriggeredEvent. # When a player activates the trigger, OnPlayerHitStopWall runs. StopTrigger.TriggeredEvent.Subscribe(OnPlayerHitStopWall) # We tell the device to start playing. # This is like flipping the switch on! MusicPlayer.Enable() # This function runs when a player hits the stop wall. # The trigger_device passes the activating agent here. OnPlayerHitStopWall(Agent : ?agent): void = # We check if the agent is a fort character (a player in the world). if (A := Agent?, Character := A.GetFortCharacter[]): # We stop the music! MusicPlayer.Disable()