# 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{})
Verse Library
verse
01 Device
Toggles player-specific boss UI widgets on or off when a button is pressed.
verse-library/creating-and-removing-widgets-in-unreal-editor-for-fortnite/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.