[Solved] Fields loading...sometimes

Hello, I’m building a trivia game and one of the categories is basically a mixture of all 4 of my main categories. I have the code set up so when this game type (I call it endless/random) is selected, a global boolean is set to true, and the events in the main trivia scene load appropriately. Although, I’ve been having a weird problem that I can’t seem to fix.

As seen here:

When the next button is clicked, and the user has not gotten the answer correctly(or didn’t answer), the bottom event block is ran.

A random number from 0-50 corresponding with potential questions is generated and loaded into a variable, as well as the Category variable being loaded with value 0-3 of the EndlessCat(egory) array.

As the game proceeds, and the next button is clicked, sometimes the variable Question_Picked will change because a new random number is rolled, however the firestore document fields are not loaded.

So it will look sometime like this

Question 1: What color is the sky? A1:Red A2:Blue A3:Yellow A4: Green

(NEXT button is pressed executing the events screenshotted above) and the following SOMETIMES happens:

Question 39: What color is the sky? A1:Red A2:Blue A3:Yellow A4: Green

I am expecting the questions and answers to change because they are linked to the question number variable. So if it is displaying question 39, but the questions and answers are from question 1, it means something is failing to load, but I can’t figure out why(and why it only happens 10% of the time).

Most times the questions will load correctly, but sometimes only the question number variable changes, and the rest stay the same. I am confused on what I’m missing, if anyone would care to help me work on this problem I’d appreciate it greatly.

Thank You.

Using your example, is there a FireStore entry for question 39? Maybe there’s an error in retrieving the data? What does the variable endlessResult have in it?

For debugging, put the result of each FireStore retrieve into a different variable, and then check what each of those variables have in them using the debugger.

What’s happening under “EndlessMode is false”? And do you know or mean to set “EndlessMode=true” under the condition of “EndlessMode” is true? What’s the current value of EndlessMode at that point?

Hey thank you for your help everyone, I didn’t know debug mode existed and I used it to see what variables were loading, problem was simply that a variable in the array was listed as “General Knowledge” when that same field doesn’t exist, as its listed as “generalknowledge” in the database, without the space. Once I removed this space the problem stopped happening.


Good to hear. I get done in by different spellings or capitalizations all the time.