I slightly changed the script so it will work. The difference in it is that i removed the word 'all' in the script where it was searching for the string "Use F1, F2, etc. keys as standard function keys"
Now i will work with the latest macOS update
on alfred_script(q)
tell application "System Preferences"
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
if UI elements enabled then
tell tab group 1 of window "Keyboard" of process "System Preferences"
click checkbox "Use F1, F2, etc. keys as standard function keys"
end tell
else
tell application "System Preferences"
set current pane ¬
to pane "com.apple.preference.universalaccess"
display dialog ¬
"UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell
tell application "System Preferences"
quit
end tell
end alfred_script