I’m trying to make a tool that can insert into a radio playlist, so then whenever the next song proximity prompt is triggered, it plays the next song in the playlist
I have two scripts parented under the radio:
Insert:
script.Parent.Touched:Connect(function(op)
if op.Name == "Handle" then
if op.Parent.Name == "drop.mp3" then
workspace.Songs.drop.Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "good days.mp3" then
workspace.Songs["good days"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "happy.mp3" then
workspace.Songs["happy"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "little loud ;).mp3" then
workspace.Songs["little loud ;)"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "morning.mp3" then
workspace.Songs["morning"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "video game.mp3" then
workspace.Songs["video game"].Parent = workspace.Playlist
op.Parent:Destroy()
end
end
end)
and the Play:
script.Parent.Touched:Connect(function(op)
if op.Name == "Handle" then
if op.Parent.Name == "drop.mp3" then
workspace.Songs.drop.Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "good days.mp3" then
workspace.Songs["good days"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "happy.mp3" then
workspace.Songs["happy"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "little loud ;).mp3" then
workspace.Songs["little loud ;)"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "morning.mp3" then
workspace.Songs["morning"].Parent = workspace.Playlist
op.Parent:Destroy()
elseif op.Parent.Name == "video game.mp3" then
workspace.Songs["video game"].Parent = workspace.Playlist
op.Parent:Destroy()
end
end
end)
The play script is where I got an error ‘invalid argument #1 to pairs’. I’m not very experienced with for loops, so I don’t know what that means.