Okay. I have no idea what the issue is at this point, but this is what's been going on, and it's bonkers.
I have an array called StarCountArray for the stars. At first, I had it set up so that after you get a star, it would set the XY value of the star from 0 to 1, then it would add the total to a Global variable called Totalstars using a Function called AddStars.
So like this:
On Function "AddStars" ---------------Set Totalstars to 0
subevent -For Each XY element ---------------- Add StarCountArray.CurValue to Totalstars
It worked like a charm, but I realized that if you got a star, then left the stage to the level select, it would still count up the total amount of stars collected, which isn't what I want.
So I tried something else.
Keeping the same function, I made 3 new global variables:
CountUp1
CountUp2
CountUp3
After you pick up a star, depending on which one you picked up, it would change the value of the corresponding variable to 1.
Then I made an event for when you reach the goal.
After you reach the goal, I have a For Each loop that sets the StarCountArray value of each star in the layout to it's corresponding CountUp variable.
I know it sets the right values because I made 3 Sprite Text objects to keep track of it, setting their values to the StarCountArray values, and every value became 1 when you reached the end of the level.
In the same For Each loop, after it does the action mentioned above, it does the AddStars Function to add the stars to the Totalstars variable.
Sounds like it should work then, right? Well... No. No it doesn't. The value of Totalstars becomes 1. ALWAYS. even after I clear another level and get all of the stars on that one. The value of Totalstars stays at 1 no matter what, but only after I clear the first level. I've looked over it several times to find errors. I couldn't find anything wrong. It doesn't make any sense.
If you read my essay of a topic, I thank you. If you think that you know what the issue is, or you think that there's something else I could try, then PLEASE tell me. I will be eternally grateful!