using { /Fortnite.com/UI }
# This is our variable.
# It holds an integer (a whole number).
# We start it at 0.
Score: integer = 0
# This function runs when the game starts.
Main<init>()<static>: void =
# We find the slider device in our level.
# Replace "MySlider" with the name of your slider.
slider := GetWorld().FindDevice<ISlider>("MySlider")
# We connect to the slider's event.
# This event fires when the slider moves.
slider.OnValueChanged().Subscribe(OnSliderChanged)
# This function runs every time the slider changes.
OnSliderChanged(_): void =
# We get the current value from the slider.
# This is a float (a number with decimals).
new_value := slider.GetValue()
# We convert it to an integer (whole number).
# We round it to the nearest whole number.
Score = Int(new_value)
# We print the score to the screen.
# This helps us see the variable change.
Print("Score is now: {Score}")
Verse Library
verse
01 Fragment
Connects a level slider device to a variable to dynamically track and display score changes in real time.
verse-library/verse-variables-and-how-values-change-during-gameplay/01-fragment.verse