Hey everyone! What I'm trying to do is count how many times a certain value appears in an array, and set a variable to that number. Here's the code I have:
What happens in the array is that when you pick up a carrot or potato, they are added to the Inventory array at an index of 0.
Now, the code above works fine when I pick up the same object, such as 3 potatoes, but once I pick up a carrot the variables both become equal to the same number when they shouldn't be. For example, if I pick up 2 carrots the CarrotCount variable becomes 2. Then, when I
pick up 1 potato, both the CarrotCount and PotatoCount variables become 3.
Does anyone know why this is happening and how I can fix it?