I am using this script for 3 different sounds regions in the map, 2 are constantly played whilst one I want to fade in as I get closer towards it and fade out

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

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)

2 comments

0

you could tween the volume of the sounds, of course, you gotta do that on the client side to prevent other players IN the region from hearing a random cut and fade in of the sound

0

The only problem is I am extremely new to scripting, how exactly do I tween the volume of the sounds