using { /Fortnite.com/Devices }
# This is our main "Controller" device.
# It will sit in the world and listen for class selections.
class ClassPickerController < creative_object:
# We need a reference to the UI device we placed in the editor
# Think of this as plugging a microphone into a speaker.
selector_device: ClassSelectorUIDevice = ClassSelectorUIDevice{}
# This function runs when the game starts
OnBegin<override>()<suspends>: void =
# 1. Listen for when a player selects a class
selector_device.SelectedClassEvent += (player, selected_class) ->
# 2. Do something with that selection
HandleClassSelection(player, selected_class)
# This is the "brain" that handles the logic
HandleClassSelection(player: Player, class_name: string): void =
# This is a simple if/else statement.
# It's like checking the storm timer: if time > 0, storm is active.
if class_name == "Hero":
# Give the player a Shotgun
# We use the 'Grant Item' device logic, but simplified for Verse
# Note: In a real setup, you might use Item Granter devices linked to this script
player.GrantWeapon(Shotgun{})
player.GrantItem(ShieldPotion{})
elif class_name == "Villain":
# Give the player a Sniper
player.GrantWeapon(SniperRifle{})
Verse Library
verse
01 Fragment
Handles player class selection and grants corresponding weapons and items based on the chosen class.
verse-library/using-class-selector-ui-devices-in-fortnite-creative/01-fragment.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.