I have this music menager and can i somehow do it so the sound will continue even when player will die, because now it resets and plays from the beggining. (Its a local script)
local Songs = {
--ID's in here
}
local SongObject = script.Parent.Song
local SongLabel = script.Parent.Parent.SongLabel
local SkipButton = script.Parent.SkipButton
local MuteButton = script.Parent.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
local player = game.Players.LocalPlayer
local SoundObject = script.Song
player.PlayerAdded:connect(funcion()
local SoundCopy = SoundObject:Clone()
SoundCopy.Parent = player
end
You could just reference the Player’s GUI itself in StarterPlayerScripts , I believe scripts inside StarterGui would still restart regardless even if the ResetOnSpawn property is set to false (Not sure though)
--LocalScript inside StarterPlayerScripts
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Songs = {
--ID's in here
}
--Change these to where your object is inside the Gui
local SongObject =
local SongLabel =
local SkipButton =
local 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
local SongObject = game.StarterGui.BtnsGui.Frame.Song
local SongLabel = game.StarterGui.BtnsGui.SongLabel
local SkipButton = game.StarterGui.BtnsGui.Frame.SkipButton
local MuteButton = game.StarterGui.BtnsGui.Frame.MuteButton
The StarterGui is replicated across the server-side, which the client will not detect its changes on
You have to reference the PlayerGui in the example I gave, put the LocalScript inside StarterPlayerScripts and try this:
--LocalScript inside StarterPlayerScripts
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Songs = {
--ID's in here
}
local GuiObject = PlayerGui:WaitForChild("BtnsGui")
local SongObject = GuiObject:WaitForChild("Frame").Song
local SongLabel = GuiObject:WaitForChild("SongLabel")
local SkipButton = GuiObject:WaitForChild("Frame").SkipButton
local MuteButton = GuiObject:WaitForChild("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
The buttons and everything works, but when you die its not only resetting the sound, but it stops it, the songlabel has the placeholder text and the buttons don’t work
Try sending a reproduction file? I don’t exactly see anything that could be resetting the song, unless if you change SongObject:Play() to SongObject:Resume()