local r=workspace.FilteringEnabled local f=script.Parent.Car.Value local a=f:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local m=require(f["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local g=0 local j=0 local n=0 script:WaitForChild("\082\101\118")for r,f in pairs(f.DriveSeat:GetChildren())do for r,a in pairs(script:GetChildren())do if f.Name==a.Name then f:Stop()wait()f:Destroy()end end end a:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",f.DriveSeat,script.Rev.SoundId,0,script.Rev.Volume,true)a:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\118")f.DriveSeat:WaitForChild("\082\101\118")while wait()do local Y=script.Parent.Values.RPM.Value if script.Parent.Values.Throttle.Value<=m.IdleThrottle/100 then j=math.max(.3,j-.2)else j=math.min(1,j+.1)end if script.Parent.Values.RPM.Value>m.Redline-m.RevBounce/4 and script.Parent.Values.Throttle.Value>m.IdleThrottle/100 then n=.5 else n=1 end if not script.Parent.IsOn.Value then g=math.max(g-.015,0)else g=1 end local d=math.max((script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*Y)/m.Redline)*g^2,script.Rev.SetPitch.Value)if r then a:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,d,script.Rev.Volume)else f.DriveSeat.Rev.Pitch=d end 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")


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.Volume,true)
handler:FireServer("playSound","Rev")
car.DriveSeat:WaitForChild("Rev")

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 Pitch = math.max((((script.Rev.SetPitch.Value + script.Rev.SetRev.Value*_RPM/_Tune.Redline))*on^2),script.Rev.SetPitch.Value)
	if FE then
		handler:FireServer("updateSound","Rev",script.Rev.SoundId,Pitch,script.Rev.Volume)
	else
		car.DriveSeat.Rev.Pitch = Pitch
	end
end
