Hangman Applescript - Need help with making this script work right

There are many variables in this script. The long list of variables of the beginning is this: pie = variables that are each character of the word chosen for hangman to find out, joe = the variables that will be set to the pie variables if any of the characters of (theanswer) is correctly guessed by the user which matches the characters from the pie variables. Star variables are what check for success guesses so guesses will not be reverted upon repeating. Jue variable is what makes sure the code repeats till that number which is equal to the number of items of a list. Letter variables are extra variables if you need to use them for sorting the code through the if statements. Not necessary though. Chancesleft is the variable to determine how many chances the user has left for guessing the word before it will say, “I’m sorry, but you suck at this game. The word was “hello.” Maybe you should quit the game since it is not your strong suit. Or you can take a shot at it and play again. Do you want to??” This code here is almost there from what I think. It just needs some variable and list setting errors to be fixed but do not know how to fix. Any help would be great. I will put the file download url in this writeup that must be placed on your desktop in order for it to work somewhat. Here is the file download to desktop link: http://dl.dropbox.com/u/6716858/hangman%20words%20test.txt. Here is the applescript code:

set justo to ""
set thedone to ""
repeat until justo is 1
	set chances to "0"
	set chancesleft to "5"
	set yump1 to ""
	set yump2 to ""
	set yump3 to ""
	set jump4 to ""
	set star1 to ""
	set star2 to ""
	set star3 to ""
	set star4 to ""
	set star5 to ""
	set star6 to ""
	set star7 to ""
	set star8 to ""
	set star9 to ""
	set star10 to ""
	set star11 to ""
	set star12 to ""
	set star13 to ""
	set star14 to ""
	set star15 to ""
	set star16 to ""
	set star17 to ""
	set star18 to ""
	set star19 to ""
	set star20 to ""
	set star21 to ""
	set star22 to ""
	set star23 to ""
	set star24 to ""
	set star25 to ""
	set star26 to ""
	set star27 to ""
	set star28 to ""
	set star29 to ""
	set star30 to ""
	set letter1 to ""
	set letter2 to ""
	set letter3 to ""
	set letter4 to ""
	set letter5 to ""
	set letter6 to ""
	set letter7 to ""
	set letter8 to ""
	set letter9 to ""
	set letter10 to ""
	set letter11 to ""
	set letter12 to ""
	set letter13 to ""
	set letter14 to ""
	set letter15 to ""
	set letter16 to ""
	set letter17 to ""
	set letter18 to ""
	set letter19 to ""
	set letter20 to ""
	set letter21 to ""
	set letter22 to ""
	set letter23 to ""
	set letter24 to ""
	set letter25 to ""
	set letter26 to ""
	set letter27 to ""
	set letter28 to ""
	set letter29 to ""
	set letter30 to ""
	set pie1 to ""
	set pie2 to ""
	set pie3 to ""
	set pie4 to ""
	set pie5 to ""
	set pie6 to ""
	set pie7 to ""
	set pie8 to ""
	set pie9 to ""
	set pie10 to ""
	set pie11 to ""
	set pie12 to ""
	set pie13 to ""
	set pie14 to ""
	set pie15 to ""
	set pie16 to ""
	set pie17 to ""
	set pie18 to ""
	set pie19 to ""
	set pie20 to ""
	set pie21 to ""
	set pie22 to ""
	set pie23 to ""
	set pie24 to ""
	set pie25 to ""
	set pie26 to ""
	set pie27 to ""
	set pie28 to ""
	set pie29 to ""
	set pie30 to ""
	set joe1 to "_"
	set joe2 to "_"
	set joe3 to "_"
	set joe4 to "_"
	set joe5 to "_"
	set joe6 to "_"
	set joe7 to "_"
	set joe8 to "_"
	set joe9 to "_"
	set joe10 to "_"
	set joe11 to "_"
	set joe12 to "_"
	set joe13 to "_"
	set joe14 to "_"
	set joe15 to "_"
	set joe16 to "_"
	set joe17 to "_"
	set joe18 to "_"
	set joe19 to "_"
	set joe20 to "_"
	set joe21 to "_"
	set joe22 to "_"
	set joe23 to "_"
	set joe24 to "_"
	set joe25 to "_"
	set joe26 to "_"
	set joe27 to "_"
	set joe28 to "_"
	set joe29 to "_"
	set joe30 to "_"
	set thejoes to ""
	set thepies to ""
	set theletters to ""
	set jelly to ""
	set theopen to ""
	set thewordlist to {}
	set thelistof5 to {}
	set thelistof4 to {}
	set thelistof3 to {}
	set thelistof10 to {}
	set thelistof11 to {}
	set thelistof12 to {}
	set thelistof13 to {}
	set thelistof14 to {}
	set thelistof15 to {}
	set thelistof1 to {}
	set jue to ""
	set junie to 0
	set julie to junie
	set belly to junie
	set hunny to junie + 1
	set jue to hunny
	try
		set thefilepath to ((path to desktop) & "HangManWordsEasy" as text)
		set unixPath to POSIX path of thefilepath
		set foo to (open for access POSIX file unixPath)
		set txt to (read foo for (get eof foo)) as list
		set yump1 to number of characters of txt as number
		close access foo
	on error
		try
			close access foo
		end try
	end try
	
	display dialog "There are " & yump1 & " characters from HangManWordsEasy." buttons "OK"
	delay 2
	try
		set thefilepath to ((path to desktop) & "HangManWordsMedium" as text)
		set unixPath to POSIX path of thefilepath
		set foo to (open for access POSIX file unixPath)
		set txt to (read foo for (get eof foo)) as list
		set yump2 to number of characters of txt as number
		close access foo
	on error
		try
			close access foo
		end try
	end try
	
	display dialog "There are " & yump2 & " letters from HangManWordsMedium." buttons "OK"
	
	delay 2
	try
		set thefilepath to ((path to desktop) & "HangManWordsHard" as text)
		set unixPath to POSIX path of thefilepath
		set foo to (open for access POSIX file unixPath)
		set txt to (read foo for (get eof foo)) as list
		set yump3 to number of characters of txt as number
		close access foo
	on error
		try
			close access foo
		end try
	end try
	
	
	display dialog "There are " & yump3 & " characters from HangManWordsHard." buttons "OK"
	
	set yump4 to yump1 + yump2 + yump3
	display dialog "There are a total of " & yump4 & " characters from HangManWordsEasy, HangManWordsMedium, and HangManWordsHard." buttons "OK"
	
	delay 2
	set thelevel to ""
	set thelevel1 to ""
	if yump4 is equal to 0 then
		set thejoes to ""
		set thepies to ""
		set theletters to ""
		set jelly to ""
		set theopen to ""
		set thewordlist to {}
		set thelistof5 to {}
		set thelistof4 to {}
		set thelistof3 to {}
		set thelistof10 to {}
		set thelistof11 to {}
		set thelistof12 to {}
		set thelistof13 to {}
		set thelistof14 to {}
		set thelistof15 to {}
		set jue to ""
		set junie to 0
		set julie to junie
		set belly to junie
		set hunny to junie + 1
		set jue to hunny
		(*set volume 6*)
		set volume 6
		say "This may take up to five minutes to save the hangman dictionary lists to the desktop. Do not delete files with the words Hangman in them unless you want to go through this process again in the future." using "Alex"
		delay 2
		set thefilepath to ((path to desktop) & "hangman words test.txt" as text)
		
		set unixPath to POSIX path of thefilepath
		set foo to (open for access POSIX file unixPath)
		set txt to every item of (read foo for (get eof foo))
		set thelistof1 to thelistof1 & txt as list
		close access foo
		try
			close access foo
		end try
		delay
		display dialog "The word list source contains " & thelistof1 & " words." buttons "OK"
		say "Twenty-five percent of the downloading process is complete. Please continue waiting patiently." using "Alex"
		set thewordlist to {}
		set thelistof5 to {}
		set thelistof4 to {}
		set thelistof3 to {}
		set thelistof10 to {}
		set thelistof11 to {}
		set thelistof12 to {}
		set thelistof13 to {}
		set thelistof14 to {}
		set thelistof15 to {}
		
		set hunk to number of words of thelistof1 as number
		display dialog "There are " & hunk & " items in thelistof1 list" buttons "OK"
		set jue to 1
		
		repeat with humble in thelistof1
			set thelistof13 to {}
			set thelistof14 to {}
			set thelistof15 to {}
			
			(*set junky to item jue of thelistof1 as text ?*)
			set thejunky to item jue of thelistof1 as text
			set jumpy to thejunky as text
			if jue is greater than hunk then
				delay
				exit repeat
			end if
			set thejunky1 to number of characters of thejunky as number
			set thelistof to jumpy
			
			if thejunky1 is greater than 2 and thejunky1 is less than 7 then
				tell humble to set thelistof3 to thelistof3 & thelistof as text
				delay 1
			end if
			if thejunky1 is greater than 6 and thejunky1 is less than 11 then
				tell humble to set thelistof4 to thelistof4 & thelistof as text
				delay 1
			end if
			if thejunky1 is greater than 10 and thejunky1 is less than 31 then
				tell humble to set thelistof5 to thelistof5 & thelistof as text
				delay 1
			end if
		end repeat
		set thelistof10 to thelistof10 & thelistof5
		set thelistof11 to thelistof11 & thelistof4
		set thelistof12 to thelistof12 & thelistof3
		set jue to jue + 1
		
		set charactercount1 to number of characters of thelistof3
		set charactercount2 to number of characters of thelistof4
		set charactercount3 to number of characters of thelistof5
		set charactercount4 to number of characters of thelistof10
		set charactercount5 to number of characters of thelistof11
		set charactercount6 to number of characters of thelistof12
		set charactercount7 to number of characters of thelistof13
		set charactercount8 to number of characters of thelistof14
		set charactercount9 to number of characters of thelistof15
		display dialog "The listof3 contains " & charactercount1 & " characters." buttons "OK"
		display dialog "The listof4 contains " & charactercount2 & " characters." buttons "OK"
		display dialog "The listof5 contains " & charactercount3 & " characters." buttons "OK"
		display dialog "The listof10 contains " & charactercount4 & " characters." buttons "OK"
		display dialog "The listof11 contains " & charactercount5 & " characters." buttons "OK"
		display dialog "The listof12 contains " & charactercount6 & " characters." buttons "OK"
		display dialog "The listof13 contains " & charactercount7 & " characters." buttons "OK"
		display dialog "The listof14 contains " & charactercount8 & " characters." buttons "OK"
		display dialog "The listof15 contains " & charactercount9 & " characters." buttons "OK"
		display dialog "The listof14 contains these words: " & thelistof14 & "." buttons "OK"
		
		set jue to 0
		say "Seventy-three percent of the downloading process is complete. Please continue waiting patiently." using "Alex"
		
		set PasswordFile3 to ((path to desktop) & "HangManWordsEasy") as text
		set PasswordFile1 to ((path to desktop) & "HangManWordsMedium") as text
		set PasswordFile4 to ((path to desktop) & "HangManWordsHard") as text
		set opener3 to POSIX path of PasswordFile3 as text
		set opener1 to POSIX path of PasswordFile1 as text
		set opener4 to POSIX path of PasswordFile4 as text
		set thefile3 to open for access file PasswordFile3 with write permission
		write thelistof3 as text to thefile3 starting at eof
		close access thefile3
		try
		on error
			
			close access thefile3
		end try
		delay 1
		set thefile1 to open for access file PasswordFile1 with write permission
		write thelistof4 as text to thefile1 starting at eof
		close access thefile1
		try
		on error
			
			close access thefile1
		end try
		delay 1
		set thefile5 to open for access file PasswordFile4 with write permission
		write thelistof5 as text to thefile5 starting at eof
		close access thefile5
		
		try
		on error
			close access thefile5
			
		end try
		delay 5
		say "Ninety-nine percent of the downloading process is complete." using "Alex"
		delay 5
		say "The downloading process is now complete. Thank you for waiting." using "Alex"
		
	end if
	delay 1
	set bump to button returned of (display dialog "Which mode would you like to try?" buttons {"Easy-peasy", "A little challenging", "Insane"})
	if bump is "Easy-peasy" then
		set thelevel to 3
		set thelevel1 to 6
		delay
		set thelistof2 to every word of thelistof3
		set thejunky3 to thejunky3 & number of items of thelistof2 as number
		set jelly to random number thejunky3
		set thewordlist to thelistof2
	end if
	if bump is "A little challenging" then
		set thelevel to 7
		set thelevel1 to 10
		delay
		set thelistof2 to every word of thelistof4
		set thejunky3 to thejunky3 & number of items of thelistof2 as number
		set jelly to random number thejunky3
		set thewordlist to thelistof2
	end if
	if bump is "Insane" then
		set thelevel to 11
		set thelevel1 to 33
		delay
		set thelistof2 to every word of thelistof5
		set thejunky3 to thejunky3 & number of items of thelistof2 as number
		set jelly to random number thejunky3
		set thewordlist to thelistof2
	end if
	set thejunky4 to ""
	set thejunky4 to thejunky3
	(* original
set thelistof2 to every item of thelistof3
set thejunky3 to number of items of thelistof2 as number
set jelly to random number thejunky3

other code = before these parentheses changed to bump instead of thejunky1
if thejunky1 is greater than 2 and thejunky1 is less than 8 then
	set thelistof2 to every item of thelistof3
	set thejunky3 to number of items of thelistof2 as number
	set jelly to random number thejunky3
end if
if thejunky1 is greater than 7 and thejunky1 is less than 14 then
	set thelistof2 to every item of thelistof4
	set thejunky3 to number of items of thelistof2 as number
	set jelly to random number thejunky3
end if
if thejunky1 is greater than 13 and thejunky1 is less than 34 then
	set thelistof2 to every item of thelistof5
	set thejunky3 to number of items of thelistof2 as number
	set jelly to random number thejunky3
end if

*)
	
	set PasswordFile3 to ((path to desktop) & "HangManWordsEasy") as text
	set PasswordFile1 to ((path to desktop) & "HangManWordsMedium") as text
	set PasswordFile4 to ((path to desktop) & "HangManWordsHard") as text
	set opener3 to POSIX path of PasswordFile3 as text
	set opener1 to POSIX path of PasswordFile1 as text
	set opener4 to POSIX path of PasswordFile4 as text
	set jue to 0
	set junie to 0
	set julie to junie
	set belly to junie
	set hunny to junie + 1
	set jue to hunny
	set jelly to random number 21
	if bump is "Easy-peasy" then set theopen to opener3 as text
	if bump is "A little challenging" then set theopen to opener1 as text
	if bump is "Insane" then set theopen to opener4 as text
	set theword1 to every item of thewordlist as list
	set theword to item jelly of theword1
	set thenumberof to number of characters of theword
	
	set yellow to every character of theword as list
	repeat thenumberof times
		
		set thejunky2 to item jue of yellow
		set thelistof8 to thejunky2
		
		if jue is 1 then set pie1 to thejunky2
		if jue is 2 then set pie2 to thejunky2
		if jue is 3 then set pie3 to thejunky2
		if jue is 4 then set pie4 to thejunky2
		if jue is 5 then set pie5 to thejunky2
		if jue is 6 then set pie6 to thejunky2
		if jue is 7 then set pie7 to thejunky2
		if jue is 8 then set pie8 to thejunky2
		if jue is 9 then set pie9 to thejunky2
		if jue is 10 then set pie10 to thejunky2
		if jue is 11 then set pie11 to thejunky2
		if jue is 12 then set pie12 to thejunky2
		if jue is 13 then set pie13 to thejunky2
		if jue is 14 then set pie14 to thejunky2
		if jue is 15 then set pie15 to thejunky2
		if jue is 16 then set pie16 to thejunky2
		if jue is 17 then set pie17 to thejunky2
		if jue is 18 then set pie18 to thejunky2
		if jue is 19 then set pie19 to thejunky2
		if jue is 20 then set pie20 to thejunky2
		if jue is 21 then set pie21 to thejunky2
		if jue is 22 then set pie22 to thejunky2
		if jue is 23 then set pie23 to thejunky2
		if jue is 24 then set pie24 to thejunky2
		if jue is 25 then set pie25 to thejunky2
		if jue is 26 then set pie26 to thejunky2
		if jue is 27 then set pie27 to thejunky2
		if jue is 28 then set pie28 to thejunky2
		if jue is 29 then set pie29 to thejunky2
		if jue is 30 then set pie30 to thejunky2
		set jue to jue + 1
	end repeat
	set jue to 1
	
	(*first we split the word to guess into letters. now we will split the user's answer into letters. finally we will set the answer to a combo of the variables with "_" at the top.*)
	
	display dialog "There are " & thenumberof & " letters in this word." buttons "OK" default button 1
	set theanswer to text returned of (display dialog "Start guessing!!" default answer "" buttons "Enter" default button 1)
	
	set thenumberof to number of characters of theanswer
	set yellow1 to every character of theanswer as list
	repeat until chancesleft is equal to 0 or thedone is 1
		
		set thejunky2 to item jue of yellow1 as text
		set thelistof8 to thejunky2
		if jue is 1 and star1 is equal to 0 and pie1 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe1 to pie1
			set star1 to 1
		else
			if jue is 1 and star1 is equal to 0 and pie1 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe1 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 1 and star1 is equal to 1 and pie1 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe1 to joe1
				end if
			end if
		end if
		if jue is 2 and star2 is equal to 0 and pie2 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe2 to pie2
			set star2 to 1
		else
			if jue is 2 and star2 is equal to 0 and pie2 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe2 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 2 and star2 is equal to 1 and pie2 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe2 to joe2
				end if
			end if
		end if
		if jue is 3 and star3 is equal to 0 and pie3 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe3 to pie3
			set star3 to 1
		else
			if jue is 3 and star3 is equal to 0 and pie3 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe3 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 3 and star3 is equal to 1 and pie3 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe3 to joe3
				end if
			end if
		end if
		if jue is 4 and star4 is equal to 0 and pie4 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe4 to pie4
			set star4 to 1
		else
			if jue is 4 and star4 is equal to 0 and pie4 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe4 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 4 and star4 is equal to 1 and pie4 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe4 to joe4
				end if
			end if
		end if
		if jue is 5 and star5 is equal to 0 and pie5 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe5 to pie5
			set star5 to 1
		else
			if jue is 5 and star5 is equal to 0 and pie5 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe5 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 5 and star5 is equal to 1 and pie5 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe5 to joe5
				end if
			end if
		end if
		if jue is 6 and star6 is equal to 0 and pie6 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe6 to pie6
			set star6 to 1
		else
			if jue is 6 and star6 is equal to 0 and pie6 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe6 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 6 and star6 is equal to 1 and pie6 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe6 to joe6
				end if
			end if
		end if
		if jue is 7 and star7 is equal to 0 and pie7 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe7 to pie7
			set star7 to 1
		else
			if jue is 7 and star7 is equal to 0 and pie7 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe7 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 7 and star7 is equal to 1 and pie7 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe7 to joe7
				end if
			end if
		end if
		if jue is 8 and star8 is equal to 0 and pie8 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe8 to pie8
			set star8 to 1
		else
			if jue is 8 and star8 is equal to 0 and pie8 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe8 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 8 and star8 is equal to 1 and pie8 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe8 to joe8
				end if
			end if
		end if
		if jue is 9 and star9 is equal to 0 and pie9 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe9 to pie9
			set star9 to 1
		else
			if jue is 9 and star9 is equal to 0 and pie9 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe9 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 9 and star9 is equal to 1 and pie9 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe9 to joe9
				end if
			end if
		end if
		if jue is 10 and star10 is equal to 0 and pie10 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe10 to pie10
			set star10 to 1
		else
			if jue is 10 and star10 is equal to 0 and pie10 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe10 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 10 and star10 is equal to 1 and pie10 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe10 to joe10
				end if
			end if
		end if
		if jue is 11 and star11 is equal to 0 and pie11 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe11 to pie11
			set star11 to 1
		else
			if jue is 11 and star11 is equal to 0 and pie11 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe11 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 11 and star11 is equal to 1 and pie11 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe11 to joe11
				end if
			end if
		end if
		if jue is 12 and star12 is equal to 0 and pie12 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe12 to pie12
			set star12 to 1
		else
			if jue is 12 and star12 is equal to 0 and pie12 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe12 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 12 and star12 is equal to 1 and pie12 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe12 to joe12
				end if
			end if
		end if
		if jue is 13 and star13 is equal to 0 and pie13 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe13 to pie13
			set star13 to 1
		else
			if jue is 13 and star13 is equal to 0 and pie13 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe13 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 13 and star13 is equal to 1 and pie13 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe13 to joe13
				end if
			end if
		end if
		if jue is 14 and star14 is equal to 0 and pie14 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe14 to pie14
			set star14 to 1
		else
			if jue is 14 and star14 is equal to 0 and pie14 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe14 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 14 and star14 is equal to 1 and pie14 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe14 to joe14
				end if
			end if
		end if
		if jue is 15 and star15 is equal to 0 and pie15 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe15 to pie15
			set star15 to 1
		else
			if jue is 15 and star15 is equal to 0 and pie15 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe15 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 15 and star15 is equal to 1 and pie15 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe15 to joe15
				end if
			end if
		end if
		if jue is 16 and star16 is equal to 0 and pie16 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe16 to pie16
			set star16 to 1
		else
			if jue is 16 and star16 is equal to 0 and pie16 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe16 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 16 and star16 is equal to 1 and pie16 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe16 to joe16
				end if
			end if
		end if
		if jue is 17 and star17 is equal to 0 and pie17 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe17 to pie17
			set star17 to 1
		else
			if jue is 17 and star17 is equal to 0 and pie17 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe17 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 17 and star17 is equal to 1 and pie17 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe17 to joe17
				end if
			end if
		end if
		if jue is 18 and star18 is equal to 0 and pie18 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe18 to pie18
			set star18 to 1
		else
			if jue is 18 and star18 is equal to 0 and pie18 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe18 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 18 and star18 is equal to 1 and pie18 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe18 to joe18
				end if
			end if
		end if
		if jue is 19 and star19 is equal to 0 and pie19 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe19 to pie19
			set star19 to 1
		else
			if jue is 19 and star19 is equal to 0 and pie19 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe19 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 19 and star19 is equal to 1 and pie19 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe19 to joe19
				end if
			end if
		end if
		if jue is 20 and star20 is equal to 0 and pie20 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe20 to pie20
			set star20 to 1
		else
			if jue is 20 and star20 is equal to 0 and pie20 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe20 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 20 and star20 is equal to 1 and pie20 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe20 to joe20
				end if
			end if
		end if
		if jue is 21 and star21 is equal to 0 and pie21 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe21 to pie21
			set star21 to 1
		else
			if jue is 21 and star21 is equal to 0 and pie21 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe21 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 21 and star21 is equal to 1 and pie21 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe21 to joe21
				end if
			end if
		end if
		if jue is 22 and star22 is equal to 0 and pie22 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe22 to pie22
			set star22 to 1
		else
			if jue is 22 and star22 is equal to 0 and pie22 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe22 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 22 and star22 is equal to 1 and pie22 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe22 to joe22
				end if
			end if
		end if
		if jue is 23 and star23 is equal to 0 and pie23 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe23 to pie23
			set star23 to 1
		else
			if jue is 23 and star23 is equal to 0 and pie23 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe23 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 23 and star23 is equal to 1 and pie23 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe23 to joe23
				end if
			end if
		end if
		if jue is 24 and star24 is equal to 0 and pie24 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe24 to pie24
			set star24 to 1
		else
			if jue is 24 and star24 is equal to 0 and pie24 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe24 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 24 and star24 is equal to 1 and pie24 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe24 to joe24
				end if
			end if
		end if
		if jue is 25 and star25 is equal to 0 and pie25 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe25 to pie25
			set star25 to 1
		else
			if jue is 25 and star25 is equal to 0 and pie25 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe25 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 25 and star25 is equal to 1 and pie25 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe25 to joe25
				end if
			end if
		end if
		if jue is 26 and star26 is equal to 0 and pie26 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe26 to pie26
			set star26 to 1
		else
			if jue is 26 and star26 is equal to 0 and pie26 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe26 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 26 and star26 is equal to 1 and pie26 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe26 to joe26
				end if
			end if
		end if
		if jue is 27 and star27 is equal to 0 and pie27 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe27 to pie27
			set star27 to 1
		else
			if jue is 27 and star27 is equal to 0 and pie27 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe27 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 27 and star27 is equal to 1 and pie27 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe27 to joe27
				end if
			end if
		end if
		if jue is 28 and star28 is equal to 0 and pie28 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe28 to pie28
			set star28 to 1
		else
			if jue is 28 and star28 is equal to 0 and pie28 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe28 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 28 and star28 is equal to 1 and pie28 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe28 to joe28
				end if
			end if
		end if
		if jue is 29 and star29 is equal to 0 and pie29 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe29 to pie29
			set star29 to 1
		else
			if jue is 29 and star29 is equal to 0 and pie29 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe29 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 29 and star29 is equal to 1 and pie29 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe29 to joe29
				end if
			end if
		end if
		if jue is 30 and star30 is equal to 0 and pie30 is equal to thejunky2 and chancesleft is greater than 0 then
			set joe30 to pie30
			set star30 to 1
		else
			if jue is 30 and star30 is equal to 0 and pie30 is not equal to thejunky2 and chancesleft is greater than 0 then
				set joe30 to "_"
				set chancesleft to chancesleft - 1
			else
				if jue is 30 and star30 is equal to 1 and pie30 is equal to thejunky2 and chancesleft is greater than 0 then
					set joe30 to joe30
				end if
			end if
		end if
		set thejoes to joe1 & joe2 & joe3 & joe4 & joe5 & joe6 & joe7 & joe8 & joe9 & joe10 & joe11 & joe12 & joe13 & joe14 & joe15 & joe16 & joe17 & joe18 & joe19 & joe20 & joe21 & joe22 & joe23 & joe24 & joe25 & joe26 & joe27 & joe28 & joe29 & joe30 as text
		set thepies to pie1 & pie2 & pie3 & pie4 & pie5 & pie6 & pie7 & pie8 & pie9 & pie10 & pie11 & pie12 & pie13 & pie14 & pie15 & pie16 & pie17 & pie18 & pie19 & pie20 & pie21 & pie22 & pie23 & pie24 & pie25 & pie26 & pie27 & pie28 & pie29 & pie30 as text
		
		set thestarter to 1
		set theender to number of characters of theword
		set thefinisher1 to characters thestarter thru theender of thejoes as text
		set thefinisher2 to characters thestarter thru theender of thepies as text
		if thefinisher2 is equal to thefinisher1 then
			set thewin to 1
			delay 2
			set theending to button returned of (display dialog "You are correct!! The word was " & theword & ". Wanna play again??" buttons {"NO", "Yes"} default button 2)
			if theending is "NO" then
				delay 2
				set thedone to 1
				exit repeat
			end if
		else
			set thewin to 0
		end if
		if chancesleft is equal to 0 then
			set theending to button returned of (display dialog "I'm sorry, but you suck at this game. The word was " & theword & ". Maybe you should quit the game since it is not your strong suit. Or you can take a shot at it and play again. Do you want to??" buttons {"NO", "Yes"} default button 2)
			if theending is "NO" then
				delay 2
				set thedone to 1
				exit repeat
			end if
		end if
		set theanswer to text returned of (display dialog "This is what you have so far: " & thefinisher1 & ". You have " & chancesleft & " chances left to guess what the word is. Guess some more!!" default answer thefinisher1 buttons "Enter" default button 1)
		set jue to jue + 1
		set thedone to 0
	end repeat
	set jue to 0
	set justo to 1
	delay 2
	exit repeat
end repeat
exit repeat

(For the code above, try replacing letter1, letter2, … to thejunky2. If not, revert back to the code before.)

Thanks and hope to hear from people on how to make this code work throughout. Anthony.

Hey, Mate I’ve attempted to fix some of your code im still working on it but i wanted to give you a preview of the progress. im on a windows operating system at the moment and can’t check the complying issues (if there are any) so when ive finished school for the day i’ll work more on my macintosh computer at home and update you on the progress. :slight_smile: by the way there are a lot of errors you have the coding out lay right just in the wrong place and missing

tell applicaiton "Finder" to set junky to junky -- EXAMPLE!

i hope i can help you :slight_smile:


set thedone to ""
repeat until justo 
    set chances to "0"
    set chancesleft to "5"
    set yump1 to ""
    set yump2 to ""
    set yump3 to ""
    set jump4 to ""
    set star1 to ""
    set star2 to ""
    set star3 to ""
    set star4 to ""
    set star5 to ""
    set star6 to ""
    set star7 to ""
    set star8 to ""
    set star9 to ""
    set star10 to ""
    set star11 to ""
    set star12 to ""
    set star13 to ""
    set star14 to ""
    set star15 to ""
    set star16 to ""
    set star17 to ""
    set star18 to ""
    set star19 to ""
    set star20 to ""
    set star21 to ""
    set star22 to ""
    set star23 to ""
    set star24 to ""
    set star25 to ""
    set star26 to ""
    set star27 to ""
    set star28 to ""
    set star29 to ""
    set star30 to ""
    set letter1 to ""
    set letter2 to ""
    set letter3 to ""
    set letter4 to ""
    set letter5 to ""
    set letter6 to ""
    set letter7 to ""
    set letter8 to ""
    set letter9 to ""
    set letter10 to ""
    set letter11 to ""
    set letter12 to ""
    set letter13 to ""
    set letter14 to ""
    set letter15 to ""
    set letter16 to ""
    set letter17 to ""
    set letter18 to ""
    set letter19 to ""
    set letter20 to ""
    set letter21 to ""
    set letter22 to ""
    set letter23 to ""
    set letter24 to ""
    set letter25 to ""
    set letter26 to ""
    set letter27 to ""
    set letter28 to ""
    set letter29 to ""
    set letter30 to ""
    set pie1 to ""
    set pie2 to ""
    set pie3 to ""
    set pie4 to ""
    set pie5 to ""
    set pie6 to ""
    set pie7 to ""
    set pie8 to ""
    set pie9 to ""
    set pie10 to ""
    set pie11 to ""
    set pie12 to ""
    set pie13 to ""
    set pie14 to ""
    set pie15 to ""
    set pie16 to ""
    set pie17 to ""
    set pie18 to ""
    set pie19 to ""
    set pie20 to ""
    set pie21 to ""
    set pie22 to ""
    set pie23 to ""
    set pie24 to ""
    set pie25 to ""
    set pie26 to ""
    set pie27 to ""
    set pie28 to ""
    set pie29 to ""
    set pie30 to ""
    set joe1 to "_"
    set joe2 to "_"
    set joe3 to "_"
    set joe4 to "_"
    set joe5 to "_"
    set joe6 to "_"
    set joe7 to "_"
    set joe8 to "_"
    set joe9 to "_"
    set joe10 to "_"
    set joe11 to "_"
    set joe12 to "_"
    set joe13 to "_"
    set joe14 to "_"
    set joe15 to "_"
    set joe16 to "_"
    set joe17 to "_"
    set joe18 to "_"
    set joe19 to "_"
    set joe20 to "_"
    set joe21 to "_"
    set joe22 to "_"
    set joe23 to "_"
    set joe24 to "_"
    set joe25 to "_"
    set joe26 to "_"
    set joe27 to "_"
    set joe28 to "_"
    set joe29 to "_"
    set joe30 to "_"
    set thejoes to ""
    set thepies to ""
    set theletters to ""
    set jelly to ""
    set theopen to ""
    set thewordlist to {}
    set thelistof5 to {}
    set thelistof4 to {}
    set thelistof3 to {}
    set thelistof10 to {}
    set thelistof11 to {}
    set thelistof12 to {}
    set thelistof13 to {}
    set thelistof14 to {}
    set thelistof15 to {}
    set thelistof1 to {}
    set jue to ""
    set junie to 0
    set julie to junie
    set belly to junie
    set hunny to junie + 1
    set jue to hunny
    try
        tell application "Finder" to set thefilepath to ((path to desktop) & "HangManWordsEasy" as text)
        set unixPath to POSIX path of thefilepath
        tell application "Finder" to set foo to (open for access POSIX file unixPath)
        set txt to (read foo for (get eof foo)) as list
        set yump1 to number of characters of txt as number
        close access foo
    on error
        try
            close access foo
        end try
    end try
    
    display dialog "There are " & yump1 & " characters from HangManWordsEasy." buttons "OK"
    delay 2
    try
       tell application "Finder" to set thefilepath to ((path to desktop) & "HangManWordsMedium" as text)
        set unixPath to POSIX path of thefilepath
        tell application "Finder" to set foo to (open for access POSIX file unixPath)
        set txt to (read foo for (get eof foo)) as list
        set yump2 to number of characters of txt as number
        close access foo
    on error
        try
            stop foo
        end try
    end try
    
    display dialog "There are " & yump2 & " letters from HangManWordsMedium." buttons "OK"
    
    delay 0.1
    try
        tell application "Finder" to set thefilepath to ((path to desktop) & "HangManWordsHard" as text)
        set unixPath to POSIX path of thefilepath
       tell application "Finder" to set foo to (open for access POSIX file unixPath)
        set txt to (read foo for (get eof foo)) as list
        set yump3 to number of characters of txt as number
        stop foo
    on error
        try
            stop foo
        end try
    end try
    
    
    display dialog "There are " & yump3 & " characters from HangManWordsHard." buttons "OK"
    
    set yump4 to yump1 + yump2 + yump3
    display dialog "There are a total of " & yump4 & " characters from HangManWordsEasy, HangManWordsMedium, and HangManWordsHard." buttons "OK"
    
    delay 1.2
    set thelevel to ""
    set thelevel1 to ""
    if yump4 is "0" then
        set thejoes to ""
        set thepies to ""
        set theletters to ""
        set jelly to ""
        set theopen to ""
        set thewordlist to {}
        set thelistof5 to {}
        set thelistof4 to {}
        set thelistof3 to {}
        set thelistof10 to {}
        set thelistof11 to {}
        set thelistof12 to {}
        set thelistof13 to {}
        set thelistof14 to {}
        set thelistof15 to {}
        set jue to ""
        set junie to "0"
        set julie to junie
        set belly to junie
try 
        set hunny to junie + 1
end try     
    set jue to hunny
        (*set volume 6*)
       tell application "Finder" to set volume to 6
        say "This may take up to five minutes to save the hangman dictionary lists to the desktop. Do not delete files with the words Hangman in them unless you want to go through this process again in the future." using "Alex"
        delay 2
        tell application "Finder" to set thefilepath to ((path to desktop) & "hangman words test.txt" as text)
        
        set unixPath to POSIX path of thefilepath
        tell application "Finder" to set foo to (open for access POSIX file unixPath)
        set txt to every item of (read foo for (get eof foo))
        set thelistof1 to thelistof1 & txt as list
        stop foo
        try
            close access foo
        end try
        delay
        display dialog "The word list source contains " & thelistof1 & " words." buttons "OK"
        say "Twenty-five percent of the downloading process is complete. Please continue waiting patiently." using "Alex"
        set thewordlist to {}
        set thelistof5 to {}
        set thelistof4 to {}
        set thelistof3 to {}
        set thelistof10 to {}
        set thelistof11 to {}
        set thelistof12 to {}
        set thelistof13 to {}
        set thelistof14 to {}
        set thelistof15 to {}
        try
        set hunk to number of words of thelistof as number
        end try 
        display dialog "There are " & hunk & " items in thelistof1 list" buttons "OK"
        set jue to 1
        
        repeat with humble in thelistof1
            set thelistof13 to {}
            set thelistof14 to {}
            set thelistof15 to {}
            
            --set junky to item jue of thelistof1 as text ?
            set thejunky to item jue of thelistof1 as text
            set jumpy to thejunky as text
try            
 if jue is greater than hunk then
                delay
                exit repeat
            end if
end try 

I’ve seen you code an maybe you could this because it it has too many flaws in it.

hangman's init()

script hangman
	property stdin : missing value
	property stdout : missing value
	property dict : missing value
	
	on init()
		--starting up the game
		set stdin to parent's hangmanStdin's alloc()'s init()
		set stdout to parent's hangmanStdout's alloc()'s init()
		set dict to parent's hangmanDictionary's alloc()'s init()
		my mainLoop()
	end init
	
	on mainLoop()
		repeat --endless
			set option to stdin's getOptions("Lobby", "What would you like to do?", {"New Game", "Quit"})
			if option is "New Game" then
				set difficulty to stdin's getOptions("New Game", "Choose your difficulty", {"Normal", "Easy", "Hard"})
				--replace this line with an automatic word generator
				set x to parent's hangmanGame's alloc()'s initWithWordAndDifficulty(dict's getWord(), difficulty)
				
				if x's startgame() is false then
					return
				else
					stdout's printf("You've scored " & x's score & " points.")
				end if
				--game is over so clear it
				set x to missing value
			else
				exit repeat
			end if
		end repeat
	end mainLoop
	
	on shouldTerminate()
		return true
	end shouldTerminate
	
	
	on alloc()
		copy me to x
		return x
	end alloc
end script

script hangmanGame
	property parent : hangman
	
	property wordToGuess : missing value
	property maxFaults : missing value
	property usedChars : missing value
	property faults : missing value
	property score : 0
	
	on initWithWordAndDifficulty(theWord, theDifficulty)
		if theDifficulty = "Hard" then
			set my maxFaults to 5
		else if theDifficulty = "Normal" then
			set my maxFaults to 8
		else --easy or any other value will be handled as easy
			set my maxFaults to 12
		end if
		set my wordToGuess to theWord
		set my usedChars to {}
		set my faults to 0
		set my score to 0
		return me
	end initWithWordAndDifficulty
	
	on startgame()
		repeat --endless
			set __prompt to "Faults Left: " & maxFaults - faults & return & "The Word: " & my makeHiddenField()
			set c to parent's stdin's getChar(__prompt)
			if c = false then
				return false
			end if
			--first check if getChar did give us any result
			if length of c is not 0 then
				--check if teh character is valid
				if c is in "abcdefghijklmnopqrstuvwxyz" then
					--check if we already checked this before
					if c is not in my usedChars then
						set end of my usedChars to c
						--check if player guessed wrong character
						if c is not in wordToGuess then
							set faults to faults + 1
						end if
					end if
				end if
			end if
			--check if player guessed all characters of word
			if my wordGuessed() then
				set my score to ((25 * (26 / (length of my usedChars))) as integer)
				return true
			end if
			--check if player reached the max faults he's allowed to make
			if my faults = my maxFaults then
				return 0
			end if
		end repeat
	end startgame
	
	on wordGuessed()
		repeat with aChar in every text item of my wordToGuess
			if aChar is not in my usedChars then
				return false
			end if
		end repeat
		return true
	end wordGuessed
	
	on makeHiddenField()
		set characterArray to {}
		repeat with aChar in every text item of my wordToGuess
			if aChar is in my usedChars then
				set end of characterArray to aChar as string
			else
				set end of characterArray to "_"
			end if
		end repeat
		set AppleScript's text item delimiters to space
		set hiddenField to characterArray as string
		set AppleScript's text item delimiters to ""
		return hiddenField
	end makeHiddenField
end script

script hangmanDictionary
	property parent : hangman
	property wordsPlayed : missing value
	property allWords : missing value
	
	on init()
		set wordsPlayed to {}
		--try to get more words from a file for example
		set allWords to {"Hangman", "Police", "Officer", "Desktop", "Pencil", "Window", "Language"}
		return me
	end init
	
	on getWord()
		set randomNr to (random number from 1 to (length of (my allWords))) as integer
		--you could do somethinh here when a word is used again
		return item randomNr of my allWords as string
	end getWord
end script

script hangmanStdin
	property parent : hangman
	
	on init()
		return me
	end init
	
	on getChar(__prompt)
		set x to display dialog __prompt buttons {"Go", "Quit"} default button "Go" default answer ""
		if button returned of x = "Quit" then
			return false
		end if
		
		if length of x's text returned = 0 then
			return ""
		end if
		
		return character 1 of x's text returned
	end getChar
	
	on getOptions(__title, __message, __options)
		return button returned of (display alert __title message __message buttons __options default button 1)
	end getOptions
end script

script hangmanStdout
	property parent : hangman
	
	on init()
		return me
	end init
	
	on printf(__message)
		display dialog __message buttons {"OK"} default button 1
	end printf
end script