Running apple script while opening atom

Hi, I’m encountering a problem that is I can not run my apple script made which switch Mac system theme by holding command-control-9. I can use the script when using any application other than Atom. When I run it I get the error below.


The workflow itself is so simple and looks no problem.

tell application "System Events"
	
	tell appearance preferences
		
		set dark mode to not dark mode
		
	end tell
	
end tell

I have set the workflow setting to “any application” .