- Home /
How to make a person answer a question only once
I'm making a game in which a person has to answer questions. I have this code which I have attached to many game objects-:
private var inRange: boolean = false;
var myStyle = new GUIStyle();
static var score:int;
public var mess: String = "Clue";
var stringToEdit : String = "Enter Here";
var finalstring:String="nil";
function OnTriggerEnter(other:Collider)
{
if (other.tag == "Player")
{
inRange = true;
}
}
function OnTriggerExit(other:Collider)
{
if (other.tag == "Player")
{
inRange = false;
}
if(score==5)
{
score=5;
}
}
function Update(){
if(finalstring==stringToEdit)
{
score=score+5;
stringToEdit="null";
}
}
function Start()
{
if(score==5)
{
score=5;
}
}
function OnGUI ()
{
if(inRange)
{
GUI.Label (Rect (10, 10, 100, 20),"Score: " +score.ToString());
// Make a text field that modifies stringToEdit.
stringToEdit = GUI.TextField (Rect (10, 50, 1000, 20), stringToEdit, 25);
GUI.Label (Rect (10, 30, 2000, 1000),"Clue: " +mess,myStyle);
}
}
The problem is that a person is able to answer a question many times, thus giving him more points. what can i do to make him answer only once
I see you went with my solution for your previous question here. If you continue using Unity Answers, please mark the correct answer (or answer you end up using) by pressing the checkmark below the thumbs. Also please give a thumbs up (when you have enough karma) to the other helpful answers. I also fixed some code formatting in your question.
Ironically, an answer to your question is: "By not marking their previous correct answers as correct."
Waiting for you to accept an answer on your previous question before considering answering here.
Answer by Sisso · Jan 21, 2014 at 01:39 PM
I think the best solution is change your code to not allow a person don't write twice.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131024im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Detecting multiples of 2 3 Answers
Calling an if statement once even when it is calling every frame? 3 Answers
Creating a Multiple Choice Game 2 Answers
Stupid question, but bow do I access a variable that is inside the same object my script is? 2 Answers
Newbie Question Regarding Variables 2 Answers