This is AlvinBlox's SoundRegion script, and I edited it a bit to try and make the music pause and resume, yet it still just restarts when you re enter the area. Can someone help find where the error is?
local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions")
local Found = false
while true do
for i, v in pairs (SoundRegionsWorkspace:GetChildren()) do
Found = false
local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
-- Loop one by one through the parts table
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
Found = true
break
else
Found = false
end
end
if Found == true then -- from here down is where i edited it to try and fix it for my purposes
-- Start playing some music
if script.Parent.SoundRegions[v.Name].IsPaused == true then
script.Parent.SoundRegions[v.Name]:Resume()
break
end
else
script.Parent.SoundRegions[v.Name]:Pause()
end
end
wait(.1)
end

4 comments
Yeah now that I look at it I saw what was wrong and I feel kind of stupid for not seeing it before, it works, but I found another problem where dying resets the timeposition on the sound.
I'm assuming this is because it's a local script, and resets upon death.
Alright
That can be easily done with few changes