I am currently trying to create a Music Area script that fades the audio as you enter and leave a part. So far, I’ve got this, it sorta works, but is VERY buggy, such as music not fading when you exit, music not fading in when you enter, music overlapping eachother etc.
(This script is the same in both parts, each has a different audio in the script named “Music”)
local Music = script.Music
Code
local Music = script.Music
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tIn = {Volume = 1}
local tOut = {Volume = 0}
local createIn = ts:Create(Music, ti, tIn)
local createOut = ts:Create(Music, ti, tOut)
script.Parent.Touched:Connect(function()
createIn:Play()
end)
script.Parent.TouchEnded:Connect(function()
createOut:Play()
end)
How might I fix this? Is there any other ways I should go about it?