Verse UI code is delayed when attempting to check player's class through a 'race'

Hello there, currently I am experiencing an issue with the code below. Whenever a player selects any button, it spawns the function inside the HandleSelectedUIButton function “GetPlayerClassIndex” which then finds the class of the player through a ‘race’. The only issue is that the race doesn’t seem to ever finish until you open the UI again in game and click another button, and then it will print out the class from the previous interaction, not the current. The Evaluator code is one I got from another helpful person on here, so not sure if the issue is in there, but I followed a tutorial on youtube for the rest of the UI code not shown below.

Also to note: The array variable “ClassCheckers” is just an array of Attribute Evaluators set to class 1-4 in that order.

HandleSelectedUIButton(Message : widget_message) : void=
    if(PlayerUI := GetPlayerUI[Message.Player], MyUI := MaybeMyUIPerPlayer[Message.Player]?, SelectedButton := text_button_base[Message.Source]):
        # Below function that is spawned finds the class of the player through a 'race'
            GetPlayersClassIndex(Message.Player, SelectedButton.GetText())
            set MaybeMyUIPerPlayer[Message.Player] = false

The code below is from another person in the community

GetPlayersClassIndex(Agent : agent, ButtonChoice : string)<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 #>

    # This Print statement below is supposed to print the current class of the player, but instead prints the previous interaction with the UI. For example, if you clicked a UI button while in class 1, no print message would show up on the log. If you then switched to class 2 and clicked a UI button again, it would display that you are class 1.

    Print("Your Selected Class is {ClassIndex + 1}")

EvaluateClass(Agent : agent, InCheckerIndex : int)<suspends>:int=
    if(ThisClassChecker := ClassCheckers[InCheckerIndex]):
        return InCheckerIndex
    Sleep(30.0) <# give other threads time to succeed #>
    return -1

Where do you set the class of the player ? Could be that HandleSelectedUIButton() gets fired before the player’s class is set but I’d need more info.

The class is automatically set on game start for each player. In this game there is a max of four players so there are four classes for each player.

Well, hard to tell, code looks okay, maybe you can double check that all your evaluators are configured well and referenced in the good order in your class_checker_device.

Also if you renamed your file or moved some devices along, it could be a good idea to remove the device and place it again, I’ve had ghost parameters coming to haunt my map even after double checking the device parameters…