# Import necessary modules using /Fortnite.com/Devices using /Verse.org/Simulation using /UnrealEngine.com/Temporary/Schemas # This is our main device script BossDevice := class(creative_device): # This is the Button device you place in the level. # Think of this as the "Trigger" for our code. var ButtonDevice : creative_button = creative_button{} # THIS IS THE MAP # Key: Player (who is looking at the screen) # Value: Optional BossUI (the widget, which might be empty) # We name it BossUIPerPlayer so we know what's inside. var BossUIPerPlayer : [player]?BossUI = map{} # This function runs when the button is pressed. # It's like the "Elimination Event" but for buttons. OnButtonPressed := function(player: player): # Check if this player already has a widget in their "locker" if current_ui := BossUIPerPlayer[player]: # If yes, remove it. This is like taking the paper off the monitor. player.RemoveWidget(current_ui) # Clear the locker so we know it's empty now BossUIPerPlayer[player] = none else: # If no, spawn a new widget for this specific player. # We pass 'player' so the UI shows only to them. new_ui := player.AddWidget(BossUI{}) # Store the new widget in their locker BossUIPerPlayer[player] = new_ui