Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

So this music playing script re-starts everytime the person dies, but I didn't want it to work like that, I just wanted the music to continue from where it was. It is a local script and is located inside the StarterGUI

local song = game.Workspace.Songs
local function playmusic()
	while true do
		song.ET:Play()
		wait(121)
		song.Bangarang:Play()
		wait(96)
		song.DarudeSand:Play()
		wait(230)
		song.Poison:Play()
		wait(123)
	end
end
playmusic()



7 comments

0

Store it in Workspace. I've done one of these and I think it should work.

0

Already tried it.

0

What I would do is to make a part and the change the parent of the sound to the part. Change the sound to max distance. It still works :v

0

There is a much simpler solution, I'll type up the answer right now

0

Can you unaccept Cyakohl's answer because it won't help anyone looking this up in the future, it isn't even correct.

0

Also, you shouldn't place a script regarding music inside of starterGUI

0

Aight done

4 answers

✓ Accepted answer

So you will need another script for this due to that infinite loop in the one you have now This one you will put in starterscripts or you might actually be able to put this script inside your other script or the other script's parent.

--just change the hierarchy so it finds humanoid
script.Parent.Humanoid.Health.Changed:Connect(function()
	script.Value1.Value = song.ET.TimePosition
	script.Value2.Value = song.Bangarang.TimePosition
	script.Value3.Value = song.DarudeSand.TimePosition
	script.Value4.Value = song.Poison.TimePosition
end)

You will need to create number values for each song and store them wherever it is easiest to access them from both scripts.

This one is your current script

local song = game.Workspace.Songs
local function playmusic()
    while true do
	song.ET.TimePosition=script.Value1.Value
        song.ET:Play()
        wait(121)
	song.Bangarang.TimePosition=script.Value2.Value
        song.Bangarang:Play()
        wait(96)
	song.DarudeSand.TimePosition=script.Value3.Value
        song.DarudeSand:Play()
        wait(230)
	song.Poison.Value4.Value
        song.Poison:Play()
        wait(123)
    end
end
playmusic()

Because I don't know the hierarchy in your game, you will have to change the hierarchies so that they match up, but this is the best solution to your problem once you get it set up.

1 comment

0

Also, this isn't part of your question, but this would allow another script to change the TimePosition of each song whenever you wanted.

What you will need to do is disable "ResetOnSpawn" on the screen gui so it will not reset the gui once respawned.

Just encountered this problem. My solution was waaaaay simpler. I've just changed "play" to "resume" and it worked :D

i have the same problem and our tips didnt help i also tried to move song to workspace didnt work heres the script:~~~~~~~~~~~~~~~~~ local MarketPlaceService = game:GetService("MarketplaceService")

local Songs = { 1837849285, 1837848642, 5410080771, 1846420141
}

local SongObject = script.Parent.Song local SongLabel = script.Parent.SongLabel local SkipButton = script.Parent.Parent.Settings.Frame.SkipButton local MuteButton = script.Parent.Parent.Settings.Frame.MuteButton

MuteButton.MouseButton1Click:Connect(function() if SongObject.Volume == 0.5 then SongObject.Volume = 0 else SongObject.Volume = 0.5 end end)

SkipButton.MouseButton1Click:Connect(function() SongObject:Stop() end)

while true do for i = 1, #Songs do local Song = Songs[i] local SongInfo = MarketPlaceService:GetProductInfo(Song)

	SongObject.SoundId = "rbxassetid://" .. Song
	SongObject:Play()
	SongLabel.Visible = true
	SongLabel.Text = SongInfo.Name
	wait(3)
	SongLabel.Visible = false
	
	repeat wait() until not SongObject.IsPlaying
end

end


This discussion is preserved as it was. New answers, comments, and votes are closed.