Hi everyone. This is my first post! I recently got a Macbook Pro, and I have been scripting some stuff on AppleScript. I tried to script something that would automatically turn off the keyboard lights for me. Can anyone tell me what is wrong with this? Thanks in advance! 
say "Do you want the keyboard lights off?"
display dialog "Do you want the keyboard lights off?" buttons {"yes", "no"}
set button_r to the button returned of the result
if the button_r is "yes" then
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
end if
tell application "System Events"
tell application process "system preferences"
click checkbox "Illuminate keyboard in low light conditions" of group 2 of tab group 2 of window "Keyboard"
end tell
end tell
if the button_r is "no" then
end if
say "Do you want the keyboard lights off?"
display dialog "Do you want the keyboard lights off?" buttons {"yes", "no"}
set button_r to the button returned of the result
if the button_r is "yes" then
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
end if
tell application "System Events"
tell application process "system preferences"
click checkbox "Illuminate keyboard in low light conditions" of group 2 of tab group 2 of window "Keyboard"
end tell
end tell
if the button_r is "no" then
end if