Issue removeing from array index other than index 0

Thank you for reply! Yes teh variable LastInventorySlotSelected is being set when i select and inventory item but it seems that once i hit the Eat button it sets it back to the default 0 since it does not = 0-49 for the button name it seems to default back to 0 even tho i have a branch before setting LastInventorySlotSelected with condition if (boxname >= 0) as shone in the image above.

The only thing i can think of is doing a switch on Name variable make 0-49 pins and have the default be 99 so if anything no slot will be deleted. but im not sure if this is a good way to go. i dont want to do anything in a way that could slow down the game during play.