Hey so I am making a footsteps script and this is a part of my script which fades in the Footsteps sound when the Player starts walking.
The issue im having is that the volume goes all the way to the max (10) despite the repeat loop supposed to be stopping when it reaches 1.5.
I’ve tried to increase the Wait() time, I used a for loop, and removed the if statement seeing if that would do anything.
I would appreciate any help, thanks.
repeat
if Break == false then
break
end
wait (0.025)
Footsteps.Volume = Footsteps.Volume + 0.1
until Footsteps.Volume == 1.5
end
Use >= instead.
TweenService might be a better fit.
1 Like
As @apenzijncoolenleuk1 Apenz1 said, you can use TweenService:
local increaseSound = function(sound, targetVolume, targetTime)
local tweenInfo = TweenInfo.new(targetTime, Enum.EasingStyle.Linear) -- Change the easing style if you want
local volumeTween = game:GetService('TweenService'):Create(sound, tweenInfo, {Volume = targetVolume})
end
-- Example:
local sound = Instance.new('Sound')
sound.Volume = 0
increaseSound(sound, 1.5, 1) -- Change these values for different results.
Depending on what you put in the function, the volume will increase slower/faster (in seconds) and the volume will get louder/softer than 1.5.
2 Likes
Thank you both for your help, fixed my problem 
1 Like