Need help with my script

Hey! So on youtube, I found this video explaining how to make a sound play when you are in a certain area. So it works, but when I die the song doesn’t replay. It just stops completely. Does anyone have any ideas on how I can fix this?

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 = 1

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)

Help would be appreciated, thanks.

1 Like

Sounds have a property called Looped that, when set to true, will make the song repeat.
image