-- Variables local main = script.Parent:WaitForChild("Main") local sound = script.Parent:WaitForChild("Sound") local songs = {5034180086,1112199032,4513732143,4606400466,621227155} -- Songs go in here (ID ONLY) local progress = main:FindFirstChild("ProgressBar").Progress local songName = main:FindFirstChild("SongName") -- Main Script while wait() do -- Repeats itself continuously sound:Stop() -- Stops the music progress.Size = UDim2.new(0,0,1,0) -- Resets the song's progressbar if not sound.IsPlaying then -- If the song has stopped local songChosen = songs[math.random(1,#songs)] -- Chooses a random sound local asset = game.MarketplaceService:GetProductInfo(songChosen) -- Gets the sound's info sound.SoundId = "rbxassetid://".. songChosen sound:Play() songName.Text = asset.Name -- Changes to text to the sound's name wait(1) -- Prevents errors progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1) -- Moves progress bar wait((sound.TimeLength)-1) -- Waits sound's time -1 end end
Try This: if doesn't work put in sever script service, I think the reason is you didn't put the player added function.
game.Players.PlayerAdded:Connect(function(plr) -- Variables local main = script.Parent:WaitForChild("Main") local sound = script.Parent:WaitForChild("Sound") local songs = {5034180086,1112199032,4513732143,4606400466,621227155} -- Songs go in here (ID ONLY) local progress = main:FindFirstChild("ProgressBar").Progress local songName = main:FindFirstChild("SongName") -- Main Script while wait() do -- Repeats itself continuously sound:Stop() -- Stops the music progress.Size = UDim2.new(0,0,1,0) -- Resets the song's progressbar if not sound.IsPlaying then -- If the song has stopped local songChosen = songs[math.random(1,#songs)] -- Chooses a random sound local asset = game.MarketplaceService:GetProductInfo(songChosen) -- Gets the sound's info sound.SoundId = "rbxassetid://".. songChosen sound:Play() songName.Text = asset.Name -- Changes to text to the sound's name wait(1) -- Prevents errors progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1) -- Moves progress bar wait((sound.TimeLength)-1) -- Waits sound's time -1 end end end)