If statement with a device event

Hey there!
In my code I’ve attached a player_counter_device to check if there is for example just 1 player in a specific area of the map. So now I wanted to make an if statement that if the Count succeeds something happens, but I have no idea how to make such an if statement.
Here’s what I’ve tried

    OnBegin<override>()<suspends>:void=
        GameStart.TriggeredEvent.Subscribe(RoundStart)

    RoundStart(Agent : ?agent) : void =
        CheckIf1Player.CompareToTarget()
        if (CheckIf1Player.CountSucceedsEvent):
            StatusPlaying.Show()
            StatusStopped.Hide()
            ChooseRandomSong()
            spawn {ChooseRandomDuration()}

Greetings!

Fakka,

Two options:

  1. Await
# Code waits here until count succeeds
CheckIf1Player.CountSucceedsEvent.Await()
# Continue here on succeed
  1. Subscribe Succes event to a function
OnBegin<override>()<suspends>:void={
    CheckIf1Player.CountSucceedsEvent.Subscribe(OnSucceed)
}
OnSucceed():void={
    # ChooseRandomSong
}
1 Like

You can’t await if it already has a player tho which is what this issue is

what do you mean, if the count changes and succeeds the await ends