Why is it always picking UI 1?

Basically, I want it to pick an inactive UI but everytime, it picks the first UI and overwrites its text, can anyone help?

        if (UIactive1 = false):
            set UIactive1 = true
            OrderWidget1.SetText(Order1UI(chosenOrder))
            Print("UI 1")
            
        else:
            if(UIactive2 = false):
                set UIactive2 = true
                OrderWidget2.SetText(Order2UI(chosenOrder))
                Print("UI 2")
            else:

                if(UIactive3 = false):
                    set UIactive3 = true
                    OrderWidget3.SetText(Order3UI(chosenOrder))
                    Print("UI 3")
                else:

                    if(UIactive4 = false):
                        set UIactive4 = true
                        OrderWidget4.SetText(Order4UI(chosenOrder))
                        Print("UI 4")
                    else:
                
                        if(UIactive5 = false):
                            set UIactive5 = true
                            OrderWidget5.SetText(Order5UI(chosenOrder))
                            Print("UI 5")

Hey nelmi! It’s not clear from the snippet you pasted where the issue is. Can you give more context of your code, and show where the variables UIactive1, UIactive2, etc are initialized and how?

I put this simple script together to show how to do what you’re doing (minus setting text on the UI), and it’s progressing through the variables correctly as you’re trying to do.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# A Verse-authored creative device that can be placed in a level
hello_world_device := class(creative_device):

    var ActiveUI:[]logic = array{false, false, false, false}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        var Current:int = 0
        loop:
            if (ActiveUI[Current] = false):
                Print("UI {Current}")
                if (set ActiveUI[Current] = true){}
            else:
                Print("Active")
                set Current += 1
            if (Current = ActiveUI.Length):
                Print("All active now")
                break

Turns out I had to initiate the variables outside of OnBegin()