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 5 years ago

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()



0
Store it in Workspace. I've done one of these and I think it should work. FadedJayden_Dev 118 — 5y
0
Already tried it. ArcanZus 61 — 5y
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 FadedJayden_Dev 118 — 5y
0
There is a much simpler solution, I'll type up the answer right now SteamG00B 1633 — 5y
View all comments (3 more)
0
Can you unaccept Cyakohl's answer because it won't help anyone looking this up in the future, it isn't even correct. SteamG00B 1633 — 5y
0
Also, you shouldn't place a script regarding music inside of starterGUI SteamG00B 1633 — 5y
0
Aight done ArcanZus 61 — 5y

4 answers

Log in to vote
2
Answered by
SteamG00B 1633 Moderation Voter
5 years ago
Edited 5 years ago

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.

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. SteamG00B 1633 — 5y
Ad
Log in to vote
1
Answered by
Cyrakohl 108
5 years ago

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

Log in to vote
0
Answered by 4 years ago

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

Log in to vote
0
Answered by 2 years ago

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

~~~~~~~~~~~~~~~~~

Answer this question