Need help with "QUIZ"

display dialog "IMPOSSIBLE QUIZ
To quit at any time, click on the IMPOSSIBLE QUIZ menu on the top and while holding shift, click force quit." buttons {"Begin", "Leave"} with title "Impossible quiz" default button 1
if button returned of the result is "Begin" then
	display dialog "Before we begin, please type your name." default answer "" with title "Impossible quiz" buttons {"OK"} default button 1
	if text returned of the result is "your name" then
		display dialog "Good, your not a complete idiot (yet). Now type your real name." default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
		if text returned of the result is "your real name" then
			set username to text returned of (display dialog "Ok, your smart. Now for sure put your real name." default answer "" buttons {"OK"} default button 1)
			display dialog "OK " & username & " now we can begin." buttons {"OK"} default button 1
			if button returned of the result is "OK" then
				display dialog "#1 What is the answer to life, the universe, and everything? 42, MY DOG, NOTHING, or 77" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
				if text returned of the result is "42" then
					display dialog "#2 Are you dead? YES, NO, MAYBE" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
					if text returned of the result is "no" then
						display dialog "#3 What was the answer to the second question?" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
						if text returned of the result is "your real name" then
							display dialog "#4 What is the sum of the numbers in the answer to #1." default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
							if text returned of the result is "6" then
								display dialog "#5 The answer is not not 1 but is not that but is not not not 2 which isn't the not answer to this question which is question 5." default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
								if text returned of the result is "2" then
									display dialog "What question number is this?" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
									if text returned of the result is "6" then
										display dialog "#7 What was your real name? I think you entered it in the beginning but I forgot." default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
										if text returned of the result is "" & username & "" then
											display dialog "#8 How many questions are on this quiz? 15, 20, or 47" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
											if text returned of the result is "15" then
												display dialog "#9 What were the other two possible answers for #8?" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
												if text returned of the result is "20 and 47" or "20 47" or "20, 47" then
													delay 3
													display dialog "#10 How many seconds of delay was between this window and the previous window?" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1
													if text returned of the result is "3" or "three" then
														display dialog "#11 What is different about this window compared to the others?" default answer "" buttons {"OK"} default button 1
														if text returned of the result is "title" or "no title" or "title missing" or "title gone" then
															display dialog "#12 HURRY! You have 6 seconds to type every letter on the keybord from left to right!" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1 giving up after 6
															if text returned of the result is "qwertyuiopasdfghjklzxcvbnm" then
																display dialog "#13 Good, now you have 8 seconds to type the symbol on the 19th key of they keybord you're using!" default answer "" with title "Impossible Quiz" buttons {"OK"} default button 1 giving up after 8
																if text returned of the result is "@" then
																	display dialog "#14 DONT CLICK THE BUTTON" with title "Impossible Quiz" buttons {"Continue"} default button 1 giving up after 4
																	if button returned of the result is "Continue" then
																		display dialog "INCORRECT PLEASE TRY AGAIN"
																	else
																		display dialog "#15 Press LISTIN to begin
				
				(Turn up your volume)" buttons {"LISTIN"} default button 1 with title "IMPOSSIBLE QUIZ"
																		say "Hello " & username & ", what I am going to want you to do is type what I am saying into the box that is about to open up. If you complete this task you will complete the impossible quiz."
																		display dialog "" default answer "" with title "IMPOSSIBLE QUIZ" buttons {"OK"} default button 1
																		if text returned of the result is "hello " & username & ", what I am going to want you to do is type what I am saying into the box that is about to open up. If you complete this task you will complete the impossible quiz." or "hello " & username & " what I am going to want you to do is type what I am saying into the box that is about to open up. If you complete this task you will complete the impossible quiz." then
																			display dialog "Congratulations " & username & " you won the Impossible Quiz! Click next to enter your name into the high scores list." buttons {"Next"} with title "YOU WON!!!!!"
																			if button returned of the result is "next" then
																				display dialog "Type your name for the high scores list" default answer "" with title "IMPOSSIBLE QUIZ NAME ENTRY" buttons {"Submit"} default button 1
																				if text returned of the result is "your name for the high scores list" then
																					
																					display dialog "Wow you actually figured that one out. Here is the high scores list.

your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list
your name for the high scores list"
																					
																				else
																					display dialog "INCORRECT PLEASE TRY AGAIN. YOU DID NOT WIN THE IMPOSSIBLE QUIZ"
																					
																				end if
																				
																			else
																				display dialog "INCORRECT PLEASE TRY AGAIN" buttons {"Quit"}
																				
																			end if
																		end if
																	end if
																end if
															else
																display dialog "INCORRECT PLEASE TRY AGAIN" buttons {"Quit"}
															end if
														else
															display dialog "INCORRECT PLEASE TRY AGAIN" buttons {"Quit"}
														end if
													end if
												end if
											end if
										end if
									end if
								end if
							end if
						end if
					end if
				end if
			end if
		end if
	end if
end if

OK here is what I have so far. It’s just a little stupid quiz I made to test my scripting skills (which I’m not very good). But one problem I’m having is that every time a question is answered incorrectly i want it to

display dialog "INCORRECT PLEASE TRY AGAIN" buttons {"Quit"}

So how do I make it say that every time a question is answered wrong? Where do I put that^^^^^^^ in the script?

And also tell me any errors you see and how I can fix it.

And on question 13 the answer is @. That’s what is on my keyboard but it’s probably different on other keyboards.

Hi,

use a handler, for example


set status to getAnswer("#1 What is the answer to life, the universe, and everything? 42, MY DOG, NOTHING, or 77", "Impossible Quiz", "Impossible Quiz", "42")
if status is false then return
set status to getAnswer("#2 Are you dead? YES, NO, MAYBE", "Impossible Quiz", "", "no")
if status is false then return

on getAnswer(msg, title, defaultAnswer, correctAnswer)
	repeat
		set t to text returned of (display dialog msg default answer defaultAnswer with title title buttons {"OK"} default button 1)
		if t = correctAnswer then
			return true
		else
			set b to button returned of (display dialog "INCORRECT PLEASE TRY AGAIN" buttons {"Quit", "Try Again"} default button 2)
			if b is "Quit" then return false
		end if
	end repeat
end getAnswer