- Home /
How can I record the total number of answers the player got correct and the got wrong in 2 different codes in javascript?
How could I make it so that when the player gets the answer correct, on a separate statistics page, the "Total Answers Correct = " goes up one and on a separate code, on a statistics page, the "Total Answers Incorrect = " goes up one?
Do you have any scripts now we could see? I would keep the total correct and incorrect in scriptA and then have scriptB call scriptA to get the values
Answer by Em3rgency · Jul 01, 2013 at 01:28 PM
http://docs.unity3d.com/Documentation/ScriptReference/Component.GetComponent.html
You can use this to get values from one script to another.
Answer by Owen-Reynolds · Jul 01, 2013 at 02:55 PM
Break it into the simplest possible thing that can can test, and write that. Anywhere specific you get stuck, you will probably be able to find it already answered here. I'd try writing and testing:
1) Right and Wrong variables that you can see changing in the Inspector only as the player answers. 2) Show those same variables anywhere, anyhow on the same quiz screen. 3) Make them into whatever nice-looking colored, new font, sentence w/spacing... you really want. 4a) in a test project, figure out a way to make two dummy "pages" and a button or key press that switches between. 4b) split your quiz and stats into pages as per 4a.
Your answer
![](https://koobas.hobune.stream/wayback/20220613105244im_/https://answers.unity.com/themes/thub/images/avi.jpg)