It has been a while since the problem has been happening, so I may as well post it here.
Before I start, my friend Collect1ve made a post which got flagged due to the fact that he wasn’t able to explain it, so that’s where I come in. His post consisted of the following.
My friend (me, Avxnturador) made this script to add more detailed sounds to a car such as when the user lets off the throttle it’ll change the engine sound to a different sound, and also have multiple sounds instead of changing the pitch of 1. It worked perfectly a few days ago however now it is glitching and after being in a game for a few seconds it will just mute a select few of the sounds at random.
So, to sum it up, I have made a script that makes car engines sound better, I called it “Avxnturador’s Sound Suite”. It consisted of a local script, getting values such as the vehicle’s RPM, which then calculated the pitch and volume for each sound. It also consisted of a server script which connects to a RemoteEvent. Once called, it would retrieve the sounds, along with the pitch and volume for each sound, and it would update it.
The sounds would fade in and out, most of them overlapping each other, so volume and pitch were updated very frequently for each and every sound.
Most of the time, the sounds worked, however recently, the sounds have been known to “break”, which consisted of the sounds not updating anymore, even though they are receiving volume and pitch values, all while the sound is still playing.
What I have done so far is this.
- Changed the table function so sounds automatically updated even if values were the same
- Made it so sounds would stop if they had no volume, made it so they would play again when there was
- Made it so sounds would never stopped, but once they would usually be inaudible, would change the volume to 1 and the pitch to 0
- Transferred every pitch and volume calculation to the server script
- Made it so when you pressed a key, every sound would duplicate, and the old sound would delete.
- Same as above, except new sounds would be created, not duplicated. Every value would transfer.
Despite all of these attempts to fix the problem, some of the solutions made it so sounds would break less frequently, however eventually, sounds would break, usually with one breaking, then the rest breaking.
Other people and I have observed that the sounds would “break” when they have low volumes. This was the case as people said they could still hear the sounds when they broke, they were just very quiet. The sounds would also not break in Studio, so I could not get any values from there. I have tested the sounds in games, such as “Pacifico 2: Playground Town”, and in that game, the sounds break after a while. I had a function return to me the volume and pitch values from the sound themselves, and they were updating correctly, even when the sounds broke. (What I mean by that is, the sounds would have their pitch and volume values updated, however the sound would still be quiet and static, instead of being loud and with a rising pitch, per se.)
The weird thing is that the script used to work without any issues, however I cannot pinpoint around when the sounds started to break, as it was other people telling me that it wouldn’t work.
I apologize if any part of this topic is unclear. If any clarification is needed, ask and I will try my best to do it.
Examples of the local and server scripts used are below.
Here’s an example of the local script code, combining every other fix I have attempted. This local script, and the sounds it affects, has the breaking sound problem.
local car = script.Parent.Car.Value
local _Tune = require(car["A-Chassis Tune"])
local handler = car:WaitForChild("AC6_Sound")
car.Body:WaitForChild("Exh")
handler:FireServer("stopSound",car.Body.Exh.RevA)
handler:FireServer("stopSound",car.Body.Exh.RevB)
handler:FireServer("stopSound",car.Body.Exh.RevC)
handler:FireServer("stopSound",car.Body.Exh.RevD)
handler:FireServer("stopSound",car.Body.Exh.RevE)
handler:FireServer("stopSound",car.Body.Exh.RevIdle)
handler:FireServer("stopSound",car.Body.Exh.RevRed)
handler:FireServer("stopSound",car.Body.Exh.RelA)
handler:FireServer("stopSound",car.Body.Exh.RelB)
handler:FireServer("stopSound",car.Body.Exh.RelC)
handler:FireServer("stopSound",car.Body.Exh.RelD)
handler:FireServer("stopSound",car.Body.Exh.RelE)
handler:FireServer("stopSound",car.Body.Exh.RelIdle)
handler:FireServer("stopSound",car.Body.Exh.RelRed)
handler:FireServer("stopSound",car.Body.Exh.Elec)
wait()
handler:FireServer("playSound",car.Body.Exh.RevA)
handler:FireServer("playSound",car.Body.Exh.RevB)
handler:FireServer("playSound",car.Body.Exh.RevC)
handler:FireServer("playSound",car.Body.Exh.RevD)
handler:FireServer("playSound",car.Body.Exh.RevE)
handler:FireServer("playSound",car.Body.Exh.RevIdle)
handler:FireServer("playSound",car.Body.Exh.RevRed)
handler:FireServer("playSound",car.Body.Exh.RelA)
handler:FireServer("playSound",car.Body.Exh.RelB)
handler:FireServer("playSound",car.Body.Exh.RelC)
handler:FireServer("playSound",car.Body.Exh.RelD)
handler:FireServer("playSound",car.Body.Exh.RelE)
handler:FireServer("playSound",car.Body.Exh.RelIdle)
handler:FireServer("playSound",car.Body.Exh.RelRed)
handler:FireServer("playSound",car.Body.Exh.Elec)
local Drive={}
for i,v in pairs(car.Wheels:GetChildren()) do if v.Name=="RL" or v.Name=="RR" or v.Name=="R" then table.insert(Drive,v) end end
local wDia = 0
for i,v in pairs(Drive) do if v.Size.x>wDia then wDia = v.Size.x end end
handler:FireServer("values",_Tune,wDia)
local reset = false
game.Players.LocalPlayer:GetMouse().keyDown:connect(function(k) if k=="u" then reset = true end end)
game["Run Service"].Stepped:connect(function()
handler:FireServer("updateSounds",script.Parent.Values.Throttle.Value,script.Parent.Values.RPM.Value,script.Parent.IsOn.Value,script.Parent.Values.Gear.Value,reset) reset = false
end)
Here is an example of the server script that hooks on to the RemoteEvent. This server script, and the sounds it affects, has the breaking sound problem.
local car = script.Parent.Parent
local F = {}
local on=0
local mlt = 1
local RevAPitch = 0.01
local RevARev = 3.05 * mlt
local RevBPitch = 0.01
local RevBRev = 2.3 * mlt
local RevCPitch = 0.01
local RevCRev = 1.85 * mlt
local RevDPitch = 0.01
local RevDRev = 1.525 * mlt
local RevEPitch = 0.01
local RevERev = 1.3 * mlt
local RelAPitch = 0.01
local RelARev = 4.1 * mlt
local RelBPitch = 0.01
local RelBRev = 1.85 * mlt
local RelCPitch = 0.01
local RelCRev = 1.85 * mlt
local RelDPitch = 0.01
local RelDRev = 1.525 * mlt
local RelEPitch = 0.01
local RelERev = 1.3 * mlt
local RevIdlePitch = .6*.75
local RevIdleRev = 2.75 * mlt
local RelIdlePitch = 1*.75
local RelIdleRev = 4.4 * mlt
local RevRedPitch = 0.01
local RevRedRev = 1.3 * mlt
local RelRedPitch = 0.01
local RelRedRev = 1.4 * mlt
local vol = 5 --Set the volume for everything below
local _Tune
local wDia
local resettime = tick()
local Sounds = {
car.Body.Exh.RevA,
car.Body.Exh.RevB,
car.Body.Exh.RevC,
car.Body.Exh.RevD,
car.Body.Exh.RevE,
car.Body.Exh.RelA,
car.Body.Exh.RelB,
car.Body.Exh.RelC,
car.Body.Exh.RelD,
car.Body.Exh.RelE,
car.Body.Exh.RevIdle,
car.Body.Exh.RelIdle,
car.Body.Exh.RevRed,
car.Body.Exh.RelRed,
car.Body.Exh.Elec
}
F.updateSounds = function(throt,_RPM,isOn,gear,reset)
if not isOn then on=math.max(on-1,0) else on=1 end
local function pitch(pit,rev) return math.max((((pit + rev*_RPM/_Tune.Redline))*on^2),pit) end
local volBase = throt*(0.5+(0.5*(math.sqrt(_RPM/_Tune.Redline))))
local relBase = (1-throt)*(0.5+(0.5*(math.sqrt(_RPM/_Tune.Redline))))
local RevAP = pitch(RevAPitch,RevARev) * on
local RevBP = pitch(RevBPitch,RevBRev) * on
local RevCP = pitch(RevCPitch,RevCRev) * on
local RevDP = pitch(RevDPitch,RevDRev) * on
local RevEP = pitch(RevEPitch,RevERev) * on
local RelAP = pitch(RelAPitch,RelARev) * on
local RelBP = pitch(RelBPitch,RelBRev) * on
local RelCP = pitch(RelCPitch,RelCRev) * on
local RelDP = pitch(RelDPitch,RelDRev) * on
local RelEP = pitch(RelEPitch,RelERev) * on
local RevIP = pitch(RevIdlePitch,RevIdleRev) * on
local RelIP = pitch(RelIdlePitch,RelIdleRev) * on
local RevRP = pitch(RevRedPitch,RevRedRev) * on
local RelRP = pitch(RelRedPitch,RelRedRev) * on
local IdleV = (1 - math.max(math.min(((_RPM/_Tune.Redline)*16)-1,1),0.001))
local RedV = math.max(math.min(((_RPM/_Tune.Redline)*100)-98,1),0.001)
local RevIV = math.max(volBase*IdleV,0.001)
local RelIV = math.max(relBase*IdleV,0.001)
local RevRV = math.max(volBase*RedV,0.001)
local RelRV = math.max(relBase*RedV,0.001)
local RevAV = math.max(volBase * (1-math.max(math.min(((_RPM/_Tune.Redline)*5)-1,1),0)) - IdleV * on,0.001)
local RevBV = math.max(volBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-1,1),0) - math.max(math.min(((_RPM/_Tune.Redline)*5)-2,1),0) * on,0.001)
local RevCV = math.max(volBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-2,1),0) - math.max(math.min(((_RPM/_Tune.Redline)*5)-3,1),0) * on,0.001)
local RevDV = math.max(volBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-3,1),0) - math.max(math.min(((_RPM/_Tune.Redline)*5)-4,1),0) * on,0.001)
local RevEV = math.max(volBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-4,1),0) - RedV * on,0.001)
local RelAV = math.max(relBase * (1-math.max(math.min(((_RPM/_Tune.Redline)*5)-1,1),0)) - IdleV * on,0.001)
local RelBV = math.max(relBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-1,1),0) - math.max(math.min(((_RPM/_Tune.Redline)*5)-2,1),0) * on,0.001)
local RelCV = math.max(relBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-2,1),0) - math.max(math.min(((_RPM/_Tune.Redline)*5)-3,1),0) * on,0.001)
local RelDV = math.max(relBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-3,1),0) - math.max(math.min(((_RPM/_Tune.Redline)*5)-4,1),0) * on,0.001)
local RelEV = math.max(relBase * math.max(math.min(((_RPM/_Tune.Redline)*5)-4,1),0) - RedV * on,0.001)
if RevAV<0.002 then
RevAV=.1
RevAP=0
end
if RevBV<0.002 then
RevBV=.1
RevBP=0
end
if RevCV<0.002 then
RevCV=.1
RevCP=0
end
if RevDV<0.002 then
RevDV=.1
RevDP=0
end
if RevEV<0.002 then
RevEV=.1
RevEP=0
end
if RelAV<0.002 then
RelAV=.1
RelAP=0
end
if RelBV<0.002 then
RelBV=.1
RelBP=0
end
if RelCV<0.002 then
RelCV=.1
RelCP=0
end
if RelDV<0.002 then
RelDV=.1
RelDP=0
end
if RelEV<0.002 then
RelEV=.1
RelEP=0
end
if IdleV<0.002 then
RevIV=.1
RelIV=.1
RevIP=0
RelIP=0
end
if RedV<0.002 then
RevRV=.1
RelRV=.1
RevRP=0
RelRP=0
end
local GRPitch = 0
if gear ~= 0 then GRPitch = _RPM/_Tune.Redline end
car.Body.Exh.RevA.Pitch = RevAP
car.Body.Exh.RevA.Volume = RevAV*vol
car.Body.Exh.RevB.Pitch = RevBP
car.Body.Exh.RevB.Volume = RevBV*vol
car.Body.Exh.RevC.Pitch = RevCP
car.Body.Exh.RevC.Volume = RevCV*vol
car.Body.Exh.RevD.Pitch = RevDP
car.Body.Exh.RevD.Volume = RevDV*vol
car.Body.Exh.RevE.Pitch = RevEP
car.Body.Exh.RevE.Volume = RevEV*vol
car.Body.Exh.RelA.Pitch = RelAP
car.Body.Exh.RelA.Volume = RelAV*vol
car.Body.Exh.RelB.Pitch = RelBP
car.Body.Exh.RelB.Volume = RelBV*vol
car.Body.Exh.RelC.Pitch = RelCP
car.Body.Exh.RelC.Volume = RelCV*vol
car.Body.Exh.RelD.Pitch = RelDP
car.Body.Exh.RelD.Volume = RelDV*vol
car.Body.Exh.RelE.Pitch = RelEP
car.Body.Exh.RelE.Volume = RelEV*vol
car.Body.Exh.RevIdle.Pitch = RevIP
car.Body.Exh.RevIdle.Volume = RevIV*vol
car.Body.Exh.RelIdle.Pitch = RelIP
car.Body.Exh.RelIdle.Volume = RelIV*vol
car.Body.Exh.RevRed.Pitch = RevRP
car.Body.Exh.RevRed.Volume = RevRV*vol
car.Body.Exh.RelRed.Pitch = RelRP
car.Body.Exh.RelRed.Volume = RelRV*vol
car.Body.Exh.Elec.Pitch = GRPitch*1.5
car.Body.Exh.Elec.Volume = car.Body.Exh.Elec.Volume/2
if reset and tick()-resettime>1 then
resettime=tick()
for _,i in pairs(Sounds) do
local new = i:Clone()
new.Parent = i.Parent
i:Destroy()
end
end
end
F.values = function(tn,wdia)
_Tune = tn
wDia = wdia
end
F.playSound = function(snd) snd:Play() end
F.stopSound = function(snd) snd:Stop() end
script.Parent.OnServerEvent:connect(function(pl,Fnc,...) F[Fnc](...) end)
car.DriveSeat.ChildRemoved:connect(function(child)
if child.Name=="SeatWeld" then
pcall(function()
F.stopSound(car.Body.Exh.RevA)
F.stopSound(car.Body.Exh.RevB)
F.stopSound(car.Body.Exh.RevC)
F.stopSound(car.Body.Exh.RevD)
F.stopSound(car.Body.Exh.RevE)
F.stopSound(car.Body.Exh.RelA)
F.stopSound(car.Body.Exh.RelB)
F.stopSound(car.Body.Exh.RelC)
F.stopSound(car.Body.Exh.RelD)
F.stopSound(car.Body.Exh.RelE)
F.stopSound(car.Body.Exh.RevIdle)
F.stopSound(car.Body.Exh.RelIdle)
F.stopSound(car.Body.Exh.RevRed)
F.stopSound(car.Body.Exh.RelRed)
F.stopSound(car.Body.Exh.Elec)
end)
end
end)
TL;DR: Sounds are being updated frequently, and they fade in and out of each other, changing volume and pitch, but after a while, the sounds no longer update, making everyone go