I have this line of code that’s linked via RemoteEvent to a GUI Hold-button.
It tweens a sound’s pitch and volume in a specific amount of time, yet if i let go and hold again before this amount of time is up, the effect won’t be right. Thus, I am trying to somehow reset the tween once the button is let go. The problem is, the script no longer recognizes the tween variable because its after an “elseif”. Any help?
elseif info == "Whistle On" then
Locomotive.Whistle.Smoke.Enabled=true
local goal = {}
goal.PlaybackSpeed=1
goal.Volume=3.2
local tweenInfo = TweenInfo.new(
.4,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
local tweenwhistle = TweenService:Create(Locomotive.Whistle.Sound, tweenInfo, goal)
tweenwhistle:Play()
Locomotive.Whistle.Sound:Play()
elseif info == "Whistle Off" then
--- somehow cancel/reset tween?
Locomotive.Whistle.Smoke.Enabled=false
Locomotive.Whistle.Sound:Stop()
Locomotive.Whistle.Sound.PlaybackSpeed=.96
Locomotive.Whistle.Sound.Volume=0