Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Music restarting everytime the player dies, how to fix it?

Asked by 4 years ago
Edited 4 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
01-- Variables
02local main = script.Parent:WaitForChild("Main")
03local sound = script.Parent:WaitForChild("Sound")
04local songs = {5034180086,1112199032,4513732143,4606400466,621227155} -- Songs go in here (ID ONLY)
05local progress = main:FindFirstChild("ProgressBar").Progress
06local songName = main:FindFirstChild("SongName")
07 
08-- Main Script
09 
10while wait() do -- Repeats itself continuously
11    sound:Stop() -- Stops the music
12    progress.Size = UDim2.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
View all 23 lines...
0
Can anyone edit my script ? crookmega312 -3 — 4y
2
Where is your music parented to? y3_th 176 — 4y
0
Starter Gui > MusicGui (ScreenGui) > MasterScript (LocalScript) crookmega312 -3 — 4y
0
Put it in StarterCharacter eyad27 8 — 4y
0
it's not working crookmega312 -3 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try This: if doesn't work put in sever script service, I think the reason is you didn't put the player added function.

01game.Players.PlayerAdded:Connect(function(plr)
02    -- Variables
03local main = script.Parent:WaitForChild("Main")
04local sound = script.Parent:WaitForChild("Sound")
05local songs = {5034180086,1112199032,4513732143,4606400466,621227155} -- Songs go in here (ID ONLY)
06local progress = main:FindFirstChild("ProgressBar").Progress
07local songName = main:FindFirstChild("SongName")
08 
09-- Main Script
10 
11while wait() do -- Repeats itself continuously
12    sound:Stop() -- Stops the music
13    progress.Size = UDim2.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
View all 25 lines...
0
I put this script in this properties it's work [Starter Gui > MusicGui (ScreenGui) > MasterScript (LocalScript)] crookmega312 -3 — 4y
0
it's not working crookmega312 -3 — 4y
Ad

Answer this question