Tracks not being added to iTunes playlist

Hi all! I’m very new to AppleScripting so I thought I’d practice by making a simple playlist generator.

So here’s my problem. My script seems to work. Script Debugger shows that multiple tracks were parsed, but nothing shows up in the playlist that the script is making. The playlist is always empty. Is this because of being logged in to iTunes Music? Any help is appreciated. :slight_smile:

set theAnswer to (display dialog "What do you what to listen to?" default answer ¬
	"New Playlist Name" buttons {"Electronic", "Indie", "Rock"} default button "Electronic")
set myplaylistName to text returned of theAnswer
set myGenre to the button returned of theAnswer

tell application "iTunes"
	make playlist with properties {name:myplaylistName}
	duplicate (tracks of library playlist 1 whose genre is myGenre)
end tell

Hi. Welcome to MacScripter.

I don’t use or script iTunes myself, but you’ll need to specify the destination for the duplicated tracks. Probably like this:

set theAnswer to (display dialog "What do you what to listen to?" default answer ¬
	"New Playlist Name" buttons {"Electronic", "Indie", "Rock"} default button "Electronic")
set myplaylistName to text returned of theAnswer
set myGenre to the button returned of theAnswer

tell application "iTunes"
	set newPlaylist to (make playlist with properties {name:myplaylistName})
	duplicate (tracks of library playlist 1 whose genre is myGenre) to newPlaylist
end tell