# Someone helped me make this code and I can't seem to implement something I want to add

**URL:** <https://forums.unrealengine.com/t/someone-helped-me-make-this-code-and-i-cant-seem-to-implement-something-i-want-to-add/1252726>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [August 6, 2023, 5:29pm UTC](https://forums.unrealengine.com/t/someone-helped-me-make-this-code-and-i-cant-seem-to-implement-something-i-want-to-add/1252726 "2023-08-06T17:29:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 6, 2023, 5:29pm UTC](https://forums.unrealengine.com/t/someone-helped-me-make-this-code-and-i-cant-seem-to-implement-something-i-want-to-add/1252726/1 "2023-08-06T17:29:47Z")

</div>

Basically, this code shuffles between an array of timers (there are 5) and picks a timer that hasn’t started yet. These timers, upon completion, should disable the conditional button that is linked to it (there are 12 buttons). I want to add that if a timer ends, it disables the corresponding conditional button. If someone could help, this would be greatly appreciated.

```auto
    ShuffleTimer(SelectedButton:conditional_button_device):void = 
        if (UnusedTimers.Length > 0):
            set UnusedTimers = Shuffle(Timers)
    
        if (NextTimer := UnusedTimers[0]):
            NextTimer.Start()

        set UnusedTimers = for:
            Index -> Timer : UnusedTimers
            Index <> 0
        do:
            Timer

    TimeIsDone(Agent:?agent):void={}

```

---

<div class="post-metadata">

**Author:** ![LoPing](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/loping/32/737300_2.png) [@LoPing](https://forums.unrealengine.com/u/LoPing)\
**Post date:** [August 6, 2023, 6:11pm UTC](https://forums.unrealengine.com/t/someone-helped-me-make-this-code-and-i-cant-seem-to-implement-something-i-want-to-add/1252726/2 "2023-08-06T18:11:25Z")

</div>

The code below compiles correctly, but I didn’t test…

```auto
# function...
DisableButtonAfter(Delay: float, SelectedButton: conditional_button_device)<suspends>: void =
    Print("in DisableButtonAfter")
    Sleep(Delay)
    SelectedButton.Disable()

# test function...
ButtonClicked(Timer: timer_device, SelectedButton: conditional_button_device): void=
    Print("ButtonClicked")
    var Delay: float = Timer.GetActiveDuration()
    spawn { DisableButtonAfter(Delay, SelectedButton) }
```

---

<div class="post-metadata">

**Author:** ![nelmi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nelmi/32/746978_2.png) [@nelmi](https://forums.unrealengine.com/u/nelmi)\
**Post date:** [August 6, 2023, 6:24pm UTC](https://forums.unrealengine.com/t/someone-helped-me-make-this-code-and-i-cant-seem-to-implement-something-i-want-to-add/1252726/3 "2023-08-06T18:24:06Z")

</div>

I see what you mean but that’s not exactly it, basically in my code, it shuffles between 5 timers and the issue is that I want the running timer to disable the button upon SuccessEvent

---

<div class="post-metadata">

**Author:** ![LoPing](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/loping/32/737300_2.png) [@LoPing](https://forums.unrealengine.com/u/LoPing)\
**Post date:** [August 6, 2023, 6:36pm UTC](https://forums.unrealengine.com/t/someone-helped-me-make-this-code-and-i-cant-seem-to-implement-something-i-want-to-add/1252726/4 "2023-08-06T18:36:09Z")

</div>

You could then listen to the timer’s Sucess event, but then keeping track of which button to disable would be a pain. Do you know the timer will succeed once the button is pressed (in which case waiting for the timer’s duration would work); or could the timer be paused, in which case you are stuck with listening to the success event.
