MacBook Pro: Can't change the screen brightness

On my MacBook Pro 2012, I can't change the screen brightness. When I click on the brightness keyboard controls, nothing happens. Under System Preferences → Displays, the Brightness slider is missing:

SP SS

I have also tried with an AppleScript and when I run it, I hear an error sound:

tell application "System Events"
    key code 107
end tell

Where does the problem come from? How do I adjust the brightness?


Solution 1:

Restarting the Mac fixed the issue for me. I can now set the screen brightness alright.

Apparently it's a mysterious bug in macOS.

Update: @uzair-hayat pointed out that changing the Display Scale in Settings will bring back the brightness slider.

Brightness Display Settings