Having trouble effectively wrapping int value

Sorry, I should’ve been more articulate. :slight_smile: The core inventory object is a single TArray, and the int ID refers to the index of that array that a given item resides in. Flipping through items is done with two arbitrary keys (I used left and right mousewheel), one key is arbitrarily labelled as Increment and one as Decrement.

The main logic, which works without problems, is to fire an event whenever either key is hit. Increment just executes ID = FMath::Clamp(ID, 0, ItemArray.Num()-1) +1, and Decrement executes ID = FMath::Clamp(ID, 0, ItemArray.Num()-1)- 1. The resulting behavior is that repeatedly hitting Increment will scroll through items until I’m at the last entry of the array, likewise Decrement scrolls back up.

What I’m trying to do with the rollback function I pasted in the first post is make it so if you hit Increment, and you’re already at the last entry, instead of just staying there, it will reset the ID to 0, and effectively send you back to the top of the list, and likewise hitting Decrement at 0 will set the ID to array.Num()-1, the bottom of the list, effectively making item selection a circle instead of a straight line.