# Can someone help me add a break to my verse code loop?

**URL:** <https://forums.unrealengine.com/t/can-someone-help-me-add-a-break-to-my-verse-code-loop/2052075>\
**Category:** Verse\
**Tags:** unreal-engine, unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [October 3, 2024, 9:38pm UTC](https://forums.unrealengine.com/t/can-someone-help-me-add-a-break-to-my-verse-code-loop/2052075 "2024-10-03T21:38:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonicGamez2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SonicGamez2](https://forums.unrealengine.com/u/SonicGamez2)\
**Post date:** [October 3, 2024, 9:38pm UTC](https://forums.unrealengine.com/t/can-someone-help-me-add-a-break-to-my-verse-code-loop/2052075/1 "2024-10-03T21:38:03Z")

</div>

I want to make this verse code loop break when a player enters the mutator zone device and also when the explosive device has exploded. but a can’t figure it out at all.

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

# A Verse-authored creative device that can be placed in a level

AttachPlayer := class (creative\_device):  
@editable MutatorZone : mutator\_zone\_device = mutator\_zone\_device{}  
@editable VFXPowerup : visual\_effect\_powerup\_device = visual\_effect\_powerup\_device{}  
@editable ExplosiveDevice : explosive\_device = explosive\_device{}  
@editable WhiteDisk : creative\_prop = creative\_prop{}  
@editable VFXSpawner : vfx\_spawner\_device = vfx\_spawner\_device{} # aAdd the radio device  
@editable VFXCreator : vfx\_creator\_device = vfx\_creator\_device{}

```
OnBegin<override>()<suspends>:void=
    VFXPowerup.ItemPickedUpEvent.Subscribe(AttachToPlayer)

AttachToPlayer(Agent : agent) : void=
    spawn:
        AttachToPlayerNew(Agent)

AttachToPlayerNew(Agent: agent)<suspends> : void=
    if(FC := Agent.GetFortCharacter[]):
        loop:
            Sleep(0.0)
            PlayerPos := FC.GetTransform().Translation
            PlayerRot := FC.GetTransform().Rotation
            spawn{WhiteDisk.MoveTo(PlayerPos + vector3{Z:= -70.0},PlayerRot, 0.1)}
            spawn{MutatorZone.MoveTo(PlayerPos, PlayerRot, 0.1)}
            spawn{ExplosiveDevice.MoveTo(PlayerPos + vector3{Z:= 120.0}, PlayerRot, 0.1)}
            spawn{VFXSpawner.MoveTo(PlayerPos + vector3{Z:= 70.0},PlayerRot, 0.1)} # Move the radio device
            spawn{VFXCreator.MoveTo(PlayerPos + vector3{Z:= 120.0}, PlayerRot, 0.1)}

```

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [October 4, 2024, 6:46am UTC](https://forums.unrealengine.com/t/can-someone-help-me-add-a-break-to-my-verse-code-loop/2052075/2 "2024-10-04T06:46:54Z")

</div>

You might want to take a look at [race expressions](https://dev.epicgames.com/documentation/en-us/uefn/race-in-verse), in your case, a valid template would be :

```auto
if(FC := Agent.GetFortCharacter[]):
    race:
        # Exit condition (explosive device)
        ExplosiveDevice.ExplodedEvent.Await()

        # Exit condition (mutator zone)
        loop:
            MutatorEnterer := MutatorZone.AgentEntersEvent.Await()
            if(MutatorEnterer = Agent):
                break # Breaks the inner loop then win the race

        # My tick update loop
        loop:
            Sleep(0.0)
            # Add your MoveTos here

```

Note that the `MoveTo` calls won’t be canceled right away when the explosive device or the mutator condition wins the race, since you’re spawning those `MoveTo` calls

---

<div class="post-metadata">

**Author:** ![SonicGamez2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SonicGamez2](https://forums.unrealengine.com/u/SonicGamez2)\
**Post date:** [October 5, 2024, 7:55pm UTC](https://forums.unrealengine.com/t/can-someone-help-me-add-a-break-to-my-verse-code-loop/2052075/3 "2024-10-05T19:55:12Z")

</div>

tysm bro!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [November 4, 2024, 7:55pm UTC](https://forums.unrealengine.com/t/can-someone-help-me-add-a-break-to-my-verse-code-loop/2052075/4 "2024-11-04T19:55:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
