Control Spotify with keyboard shortcuts

Hi! I'm trying to control spotify(especially play and pause) with a keyboard shortcut. I'm unsing Apple Script, but nothing happens when i click Run Script to test it:

tell application "Spotify"
    playpause
end tell

Any ideas how to solve this problem? My main goal is to force the F8 button(play/pause) to always control Spotify.

Ok, so my solution to this problem was to create an app using Script Editor. Create a new script with this:

if application "Spotify" is running then
	tell application "Spotify" to playpause
end if

Click File and Export and select Application as the file format. I paired the launch application action for the play button in BTT and selected this application for it. The app icon will pop up when it runs on your dock, but you can actually hide that: macos - How to remove the dock icon of a shell executable? - Stack Overflow

I think you could just send a keyboard shortcut (space bar) to Spotify...

Hm... that does work. Thanks!