I have been trying to “animate” a sound to get gradually louder when a certain IntValue in-game is reached. I’m beginning to wonder if it’s even possible to tween volume.
Here’s my script, I really appreciate the help, along with any other advice!
local surge = game.Workspace:WaitForChild("Values"):WaitForChild("SURGE")
local light = script.Parent.SurfaceLight
local buzz = script.Parent
local TweenService = game:GetService("TweenService")
surge.Changed:Connect(function()
if surge.Value >= 1000 then
local info = TweenInfo.new(
5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local goals =
{
Volume = 10;
}
local EarPopper = TweenService:Create(buzz, info, goals)
wait(1)
EarPopper:Play()
end
end)
1.You could instead use a simple for loop if you wanted.
2.I have just tested it out and it works perfect.
local surge = game.Workspace:WaitForChild("Values"):WaitForChild("SURGE")
local buzz = script.Sound
local TweenService = game:GetService("TweenService")
surge.Changed:Connect(function()
if surge.Value >= 1000 then
local info = TweenInfo.new(
5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local goals ={Volume = 10}
local EarPopper = TweenService:Create(buzz, info, goals)
EarPopper:Play()
end
end)
local audio = workspace:WaitForChild("audioName")
for volume = 1, 0, -0.01 do
audio.Volume = volume
wait()
end
audio:Stop()
1 is the initial value of volume
0 is the final value that volume will reach
-0.01 is the step value, meaning volume will decrease by 0.01 on each iteration