I have made a quiz game and would like to know how to stop the user from continuing if an answer is incorrect

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Juan

The following code allows me to give the player multichoice options and for them to answer them correctly or incorrectly. At the moment, I would like the player to move on with the game only when they answer the question correctly, otherwise if they answer incorrectly they cannot move to the next question until they press the correct answer.

extends Node

export(Resource) var bd_quiz
export(Color) var color_right
export(Color) var color_wrong

var buttons:=
var index:= 0
var quiz_shuffle :=

onready var questions_text:= $question_info/txt_question

func _ready()-> void:
for _button in $question_holder.get_children():
quiz_shuffle = randomize_array(bd_quiz.bd)

func load_quiz()-> void:
if index >= bd_quiz.bd.size():


questions_text.text = str(bd_quiz.bd[index].question_info)

var options = randomize_array(bd_quiz.bd[index].options)

for i in buttons.size():
	buttons[i].text = str(options[i])
	buttons[i].connect("pressed", self, "buttons_answer", [buttons[i]])

func buttons_answer(button) → void:
if bd_quiz.bd[index].correct == button.text:
button.modulate = color_right
button.modulate = color_wrong

yield(get_tree().create_timer(1), "timeout")
for bt in buttons:
	bt.modulate = Color.white
	bt.disconnect("pressed", self, "buttons_answer")
	index = 1

func randomize_array(array : Array) → Array:
var array_temp := array
return array_temp

Also, when I’d like to know how I can embed this program into my level, as a popup that appears when the play interacts with one of my objects, and disappear when the user enters the correct code.

Can you add the question and option image of the game?

Sample :
4+5 = ?
a = 5 , b = 7 , c = 10 , d = 9
If he chooses the correct answer, he will level up. If he chooses the wrong answer, start over or etc…
if d == true:
print(“level up”)
print(“start over or etc…”)

ramazan | 2022-01-26 20:24

What does RAM stand for?
Random Access Memory
Repeat Access Memory
Range Area Minimum
Regression Axis Mean

What does HTML stand for?
Hard texture modular List
Hash Tile Mesh Line
Hyper Text Mark Up Language
Higher Tier Marking Language

I would like for the user to click a question, and if the answer is right to move on to the next question. And if the answer is wrong to stay on the same page

Juan | 2022-01-26 20:29

same_scene = get_tree().get_current_scene()

Change scenes manually — Godot Engine (stable) documentation in English

Using SceneTree — Godot Engine (stable) documentation in English
and don’t use it:
“yield(get_tree().create_timer(1), “timeout”)”
because you make a time and it always stays on the tree.

var t = Timer.new()
func example():
  yield(t, "timeout")
  print("bla bla")

ramazan | 2022-01-26 20:38

I made this piece of code. What do you make of it?

var correct = color_right
var incorrect = color_wrong

func stop_gameplay():
if bd_quiz.bd[index] == incorrect:
get_tree().paused= false
bd_quiz.bd[index] == correct

Juan | 2022-01-26 21:23