Music resets when I die

I have a script for sound regions, but when I die and respawn in the SAME sound region the song resets and goes back from the beggining, is there anything I can do so it won’t reset?

Script:
local plr = game.Players.LocalPlayer

local soundRegions = workspace:WaitForChild(“SoundRegions”)
soundRegions = soundRegions:GetChildren()

local soundManagement = {}

for _,region in pairs(soundRegions) do

local info = {}

local region3 = Region3.new(region.Position-(region.Size/2),region.Position+(region.Size/2))
region.Transparency = .8

info.Region = region3
info.Sound = script.SoundRegions:FindFirstChild(region.name).Sound

table.insert(soundManagement,info)

end

game:GetService(“RunService”).RenderStepped:Connect(function()

for _,soundInfo in pairs(soundManagement) do

local region = soundInfo.Region
local sound = soundInfo.Sound
local parts = workspace:FindPartsInRegion3WithWhiteList(region,plr.Character:GetDescendants())

if #parts > 0 then

 if not sound.IsPlaying then

 sound:Play()

end

else

sound:Stop()

end
end
end)

Where is the script stored? If it’s in a GUI as a container, make sure the GUI has ResetOnSpawn set to false. If it’s not in a GUI, make sure it’s in StarterPlayerScripts and not StarterCharacterScripts as the character is destroyed when you die.

The script is placed in the StarterGUI

image

Have the GUI, ResetOnDeath (I think thats the property) to false.

wait nvm its not in a gui why is it in starter gui

Move it to StarterPlayerScripts, there the scripts don’t restart.

1 Like

I think this topic belongs in #help-and-feedback:scripting-support

anyways I think you can use this to solve your problem

1 Like

I just tried that but the song still restarts when I respawn.

what do you mean tried it? None of it is even parented under a screen gui in the first place