Script:
local main = script.Parent:WaitForChild("Main")
local sound = workspace.Sound
local songs = {2176524543,656855875,232006192,1416455255,2502315553,417456487,1211850087,2830430159,2191727105,1092031675,2203113696,2122692250,1228552531,2274654841}
local progress = main:FindFirstChild("ProgressBar").Progress
local songName = main:FindFirstChild("SongName")
--V Main Script V
while wait() do
sound:Stop()
progress.Size = UDim2.new(0,0,1,0)
if not sound.IsPlaying then
local songChosen = songs[math.random(1,#songs)]
local asset = game.MarketplaceService:GetProductInfo(songChosen)
sound.SoundId = "rbxassetid://".. songChosen
sound:Play()
songName.Text = asset.Name
wait(1)
progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1)
wait((sound.TimeLength)-1)
end
end
As has been said, you need to play it from a Script and not a LocalScript. To test this out, simply create a new Script in workspace, put something like
script:FindFirstChild("Music"):Play()
in it, and add your music as a child of the script, making sure that the music is named "Music".
Edit: Fixed grammar, also fixed the code by replacing the period before Play with a colon.