How to stack items in inventory?

ItemToAdd should be a local variable and passed into the function directly otherwise you could get the wrong data.

same with your other variables there, ShouldStack/Index make sure they’re all local variables