The below code should do what you want. It correctly printed the selected class index when I tried it in game.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.
# A Verse-authored creative device that can be placed in a level
class_checker_device := class(creative_device):
@editable
ClassCheckers : []attribute_evaluator_device = array{}
@editable
Button : button_device = button_device{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Button.InteractedWithEvent.Subscribe(OnButtonPressed) <# Provides a way for this code to be ran #>
OnButtonPressed(Agent:agent):void=
spawn:
GetPlayersClassIndex(Agent) <# spawn our suspends function #>
GetPlayersClassIndex(Agent:agent)<suspends>:void=
ClassIndex:int = race: <# This race evaluates all 4 of the following things at the same time, the first one that responds is the winner (and its value is used to set ClassIndex) the others get canceled #>
EvaluateClass(Agent,0)
EvaluateClass(Agent,1)
EvaluateClass(Agent,2)
EvaluateClass(Agent,3)
Print("Your Selected Class is {ClassIndex + 1}") <# our array starts at zero, Fortnite's class indexes start at 1 #>
EvaluateClass(Agent:agent,InCheckerIndex:int)<suspends>:int=
if(L_ClassChecker:=ClassCheckers[InCheckerIndex]):
L_ClassChecker.EvaluateAgent(Agent)
L_ClassChecker.PassEvent.Await()
return InCheckerIndex
Sleep(30.0) <# give other threads time to succeed #>
return -1