local B=workspace.FilteringEnabled local H=script.Parent.Car.Value local t=H:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local E=require(H["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local g=0 local W=0 local d=0 script:WaitForChild("\082\101\118")script:WaitForChild("\069\108\101\099")for B,H in pairs(H.DriveSeat:GetChildren())do for B,t in pairs(script:GetChildren())do if H.Name==t.Name then H:Stop()wait()H:Destroy()end end end t:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",H.DriveSeat,script.Rev.SoundId,0,script.Rev.SetVol.Value,true)t:FireServer("\110\101\119\083\111\117\110\100","\069\108\101\099",H.DriveSeat,script.Elec.SoundId,0,script.Elec.SetVol.Value,true)t:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\118")t:FireServer("\112\108\097\121\083\111\117\110\100","\069\108\101\099")H.DriveSeat:WaitForChild("\082\101\118")H.DriveSeat:WaitForChild("\069\108\101\099")while wait()do local B=script.Parent.Values.RPM.Value if script.Parent.Values.Throttle.Value<=E.IdleThrottle/100 then W=math.max(.3,W-.2)else W=math.min(1,W+.1)end if script.Parent.Values.RPM.Value>E.Redline-E.RevBounce/4 and script.Parent.Values.Throttle.Value>E.IdleThrottle/100 then d=.5 else d=1 end if not script.Parent.IsOn.Value then g=math.max(g-.015,0)else g=1 end local H=script.Rev.SetVol.Value local U=script.Elec.SetVol.Value if not E.Engine then H=0 end if not E.Electric then U=0 end local D=math.max((script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*B)/E.Redline)*g^2,script.Rev.SetPitch.Value)local z=math.max((script.Elec.SetPitch.Value+(script.Elec.SetRev.Value*B)/E.Redline)*g^2,script.Elec.SetPitch.Value)t:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,D,H)t:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\069\108\101\099",script.Elec.SoundId,z,U)end

local FE = workspace.FilteringEnabled
local car = script.Parent.Car.Value
local handler = car:WaitForChild("AC6_FE_Sounds")
local _Tune = require(car["A-Chassis Tune"])
local on = 0
local throt=0
local redline=0

script:WaitForChild("Rev")
script:WaitForChild("Elec")

for i,v in pairs(car.DriveSeat:GetChildren()) do
	for _,a in pairs(script:GetChildren()) do
		if v.Name==a.Name then v:Stop() wait() v:Destroy() end
	end
end

handler:FireServer("newSound","Rev",car.DriveSeat,script.Rev.SoundId,0,script.Rev.SetVol.Value,true)
handler:FireServer("newSound","Elec",car.DriveSeat,script.Elec.SoundId,0,script.Elec.SetVol.Value,true)
handler:FireServer("playSound","Rev")
handler:FireServer("playSound","Elec")
car.DriveSeat:WaitForChild("Rev")
car.DriveSeat:WaitForChild("Elec")

while wait() do
	local _RPM = script.Parent.Values.RPM.Value
	
	if script.Parent.Values.Throttle.Value <= _Tune.IdleThrottle/100 then
		throt = math.max(.3,throt-.2)	
	else
		throt = math.min(1,throt+.1)	
	end	
	if script.Parent.Values.RPM.Value > _Tune.Redline-_Tune.RevBounce/4 and script.Parent.Values.Throttle.Value > _Tune.IdleThrottle/100 then
		redline=.5
	else
		redline=1
	end
	if not script.Parent.IsOn.Value then on=math.max(on-.015,0) else on=1 end
	local RevVol = script.Rev.SetVol.Value
	local ElecVol = script.Elec.SetVol.Value
	if not _Tune.Engine then RevVol = 0 end
	if not _Tune.Electric then ElecVol = 0 end
	local RevPitch = math.max((((script.Rev.SetPitch.Value + script.Rev.SetRev.Value*_RPM/_Tune.Redline))*on^2),script.Rev.SetPitch.Value)
	local ElecPitch = math.max((((script.Elec.SetPitch.Value + script.Elec.SetRev.Value*_RPM/_Tune.Redline))*on^2),script.Elec.SetPitch.Value)
	handler:FireServer("updateSound","Rev",script.Rev.SoundId,RevPitch,RevVol)
	handler:FireServer("updateSound","Elec",script.Elec.SoundId,ElecPitch,ElecVol)
end
