# no-rollback effect struggle

**URL:** <https://forums.unrealengine.com/t/no-rollback-effect-struggle/2111361>\
**Category:** Verse\
**Tags:** unreal-engine, unreal-editor-for-fortnite, question, fortnite\
**Created:** [November 8, 2024, 2:14pm UTC](https://forums.unrealengine.com/t/no-rollback-effect-struggle/2111361 "2024-11-08T14:14:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoulNetworX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulNetworX](https://forums.unrealengine.com/u/SoulNetworX)\
**Post date:** [November 8, 2024, 2:14pm UTC](https://forums.unrealengine.com/t/no-rollback-effect-struggle/2111361/1 "2024-11-08T14:14:58Z")

</div>

Hello there,  
trying my first steps into verse but stumbling here and there. So far I’ve been able to save myself with tutorials or Google, but no approach has helped here yet.

With the line “RollItem(pool, Agent)” I get the error “This invocation calls a function that has the ‘no\_rollback’ effect, which is not allowed by its context.(3512)”

What am I doing wrong?

Here is the whole code:

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }

loot_pool_manager := class(creative_device):

    @editable
    Button: button_device = button_device{}

    @editable
    ItemGranter: item_granter_device = item_granter_device{}

    @editable
    Pools: [] loot_pool = array{loot_pool{}}

    OnBegin<override>()<suspends>: void=
        Button.InteractedWithEvent.Subscribe(OnTestButton)

    OnTestButton(Agent: agent) : void=
        Print("Grant Item")
        if:
            var pool :loot_pool = Pools[0]
            RollItem(pool, Agent) # <-- THIS LINE FAILS
            
        else:
            Print("Roll failed")

    
    RollItem(Pool: loot_pool, Agent: agent)<decides> : void =
        var roll : int = GetRandomInt(1, 100)
        
        for (i -> Item : Pool.DropChances):
            if (100 - Item.Chance >= roll):
                Print("Item {Item.Chance} rolled {roll}")
                Pool.ItemGranter.GrantItemIndex(Agent, i)        
    

loot_pool := class<concrete>():
    @editable
    Name: string = ""

    @editable
    ItemGranter: item_granter_device = item_granter_device{}

    @editable
    DropChances: [] drop_chance = array{drop_chance{}}

drop_chance := class<concrete>():
    @editable
    Chance : int = 0

    @editable
    Amount : vector2 = vector2{X := 1.0, Y := 2.0}

```

---

<div class="post-metadata">

**Author:** ![Mineblo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mineblo/32/1203575_2.png) [@Mineblo](https://forums.unrealengine.com/u/Mineblo)\
**Post date:** [November 8, 2024, 10:05pm UTC](https://forums.unrealengine.com/t/no-rollback-effect-struggle/2111361/2 "2024-11-08T22:05:28Z")

</div>

> [@SoulNetworX](#):
>
> `RollItem(pool, Agent) # <-- THIS LINE FAILS`

replace with `RollItem[pool,Agent]`

---

<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:** [November 9, 2024, 9:26am UTC](https://forums.unrealengine.com/t/no-rollback-effect-struggle/2111361/3 "2024-11-09T09:26:33Z")

</div>

Because **GrantItemIndex()** is `<no_rollback>` you can’t make your method `<decides>`, even though it would make sense, I don’t think it’s possible as of v32.00, they’re making changes to the specifiers though

What you can do for now is either trigger an `event` when the roll succeeds or make the method return a `logic`

Logic method

```auto
RollItem(Agent: agent):logic=
    Granter := GetGranter()
    
    if (false?):
        Granter.GrantItem(Agent)
        true
    else:
        false

Test(Agent: agent)<suspends>:void=
    DidRoll := RollItem(Agent)
    if(DidRoll?):
        # Roll Succeeded

```

Event method

```auto
RollSucceededEvent : event(agent) = event(agent){}

RollItem(Agent: agent):void=
    Granter := GetGranter()

    if (false?):
        Granter.GrantItem(Agent)
        RollSucceededEvent.Signal(Agent)

OnBegin()<suspends>:void=
    loop:
        Agent := RollSucceededEvent.Await()
        # Roll Succeeded

```
