Modifying "User interface sound effects" with applescript
System Preferences and the Sounds prefpane don't have direct ways to script this. But you can use regular UI scripting in AppleScript:

tell application "System Preferences"
    reveal anchor "effects" of pane id "com.apple.preference.sound"
end tell

tell application "System Events"
    tell process "System Preferences"
        if value of theBox is not 1 then
            click checkbox 1 of tab group 1 of window 1
        end if
    end tell
end tell


Or if you want to set a certain value rather than just toggle the checkbox:

tell application "System Preferences"
    reveal anchor "effects" of pane id "com.apple.preference.sound"
end tell

tell application "System Events"
    tell process "System Preferences"
        set theBox to checkbox 1 of tab group 1 of window 1
        if value of theBox is not 1 then -- or "is 1"
            click theBox
        end if
    end tell
end tell


You can also explicitly say checkbox "Play user interface sound effects" of ... instead of just checkbox 1, but I'm not sure how this behaves with localizations.