What is wrong with my AppleScript code?
What is wrong with my code, in applescript it does not type like it is supposed to sometimes. Can someone help fix my code?
tell application "System Events"
set textToType to "pls"
delay 1
set textToType2 to "i"
delay 1
set textToType3 to "pls hunt"
delay 1
set textToType4 to "pls dig"
delay 1
set textTotype5 to "pls use horse"
delay 1
set textToType6 to "pls beg"
delay 1
set textToType7 to "pls daily"
delay 1
set textToType8 to "pls use daily"
delay 1
repeat
set x1 to random number from 6 to 9
set x2 to random number from 6 to 9
set x3 to random number from 6 to 9
set x4 to random number from 6 to 9
set x5 to random number from 6 to 9
set x6 to random number from 6 to 9
set x7 to random number from 6 to 9
set x8 to random number from 6 to 9
set commandChoice to " crime"
set commandChoice5 to " use horse"
set commandList to {" beg", " fish"}
set commandList2 to {"", ""}
set commandList3 to {" hunt", " dig"}
set commandList4 to {"", ""}
set commandList5 to {" scout", " hl"}
set commandList6 to {"", ""}
set commandChoice8 to " crime"
set item 1 of commandList2 to some item of commandList
set item 2 of commandList2 to some item of commandList
repeat until item 1 of commandList2 is not item 2 of commandList2
set item 2 of commandList2 to some item of commandList
end repeat
set {commandChoice1, commandChoice2} to commandList2
set item 1 of commandList4 to some item of commandList3
set item 2 of commandList4 to some item of commandList3
repeat until item 1 of commandList4 is not item 2 of commandList4
set item 2 of commandList4 to some item of commandList3
end repeat
set {commandChoice3, commandChoice4} to commandList4
set item 1 of commandList6 to some item of commandList5
set item 2 of commandList6 to some item of commandList5
repeat until item 1 of commandList6 is not item 2 of commandList6
set item 2 of commandList4 to some item of commandList5
end repeat
set {commandChoice6, commandChoice7} to commandList6
delay x5
keystroke textToType & commandChoice1
keystroke return
delay x1
keystroke textToType & commandChoice2
keystroke return
delay x2
keystroke textToType & commandChoice3
keystroke return
delay x3
keystroke textToType & commandChoice4
keystroke return
delay x4
keystroke textToType & commandChoice5
keystroke return
delay x6
keystroke textToType & commandChoice6
keystroke return
delay x7
keystroke textToType & commandChoice7
keystroke return
delay x8
keystroke textToType & commandChoice8
keystroke return
end repeat
end tell
[Re-Titled by Moderator]