How can I make this sound area script use Tweens?

By extension of this, I’m not sure how to make waits work in a constant loop because they always seem to get cancelled out

Here’s the script:

local AreaSounds = Instance.new("Sound", script)
AreaSounds.Looped = true
local plr = script.Parent
local Presser = plr:WaitForChild("HumanoidRootPart")
local DifferentAreas = workspace:WaitForChild("Areas")
local CurrentArea = nil

game:GetService("RunService").Heartbeat:Connect(function()
	local raycast = Ray.new(Presser.Position, Presser.CFrame.UpVector * -1000)
	local part = workspace:FindPartOnRayWithWhitelist(raycast, {DifferentAreas})
	if part and part.Parent == DifferentAreas then
		if part ~= CurrentArea then
			CurrentArea = part
			AreaSounds.SoundId = CurrentArea.Sound.SoundId
			AreaSounds.Volume = 1
		end 
	else
		CurrentArea = nil
		AreaSounds.Volume = 0
	end
end)

I’m hoping to make it fade out before playing the sound and then back in but I’ve tried everything I can think of and I’m not sure, it just seems to cut straight to the sound playing
Thanks in advance

1 Like