01 | -- Variables |
02 | local main = script.Parent:WaitForChild( "Main" ) |
03 | local sound = script.Parent:WaitForChild( "Sound" ) |
04 | local songs = { 5034180086 , 1112199032 , 4513732143 , 4606400466 , 621227155 } -- Songs go in here (ID ONLY) |
05 | local progress = main:FindFirstChild( "ProgressBar" ).Progress |
06 | local songName = main:FindFirstChild( "SongName" ) |
07 |
08 | -- Main Script |
09 |
10 | while wait() do -- Repeats itself continuously |
11 | sound:Stop() -- Stops the music |
12 | progress.Size = UDim 2. new( 0 , 0 , 1 , 0 ) -- Resets the song's progressbar |
13 | if not sound.IsPlaying then -- If the song has stopped |
14 | local songChosen = songs [ math.random( 1 ,#songs) ] -- Chooses a random sound |
15 | local asset = game.MarketplaceService:GetProductInfo(songChosen) -- Gets the sound's info |
Try This: if doesn't work put in sever script service, I think the reason is you didn't put the player added function.
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | -- Variables |
03 | local main = script.Parent:WaitForChild( "Main" ) |
04 | local sound = script.Parent:WaitForChild( "Sound" ) |
05 | local songs = { 5034180086 , 1112199032 , 4513732143 , 4606400466 , 621227155 } -- Songs go in here (ID ONLY) |
06 | local progress = main:FindFirstChild( "ProgressBar" ).Progress |
07 | local songName = main:FindFirstChild( "SongName" ) |
08 |
09 | -- Main Script |
10 |
11 | while wait() do -- Repeats itself continuously |
12 | sound:Stop() -- Stops the music |
13 | progress.Size = UDim 2. new( 0 , 0 , 1 , 0 ) -- Resets the song's progressbar |
14 | if not sound.IsPlaying then -- If the song has stopped |
15 | local songChosen = songs [ math.random( 1 ,#songs) ] -- Chooses a random sound |