local s=true local Z=script.Parent.Car.Value local A=Z:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local M=require(Z["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local H=0 local h=0 local u=0 local q=0 local E=0 local r=0 local v=0 local Q=0 local D=0 script:WaitForChild("\082\101\118")script.Parent.Values.Gear.Changed:connect(function()h=1 if script.Parent.Values.RPM.Value>5000 then D=.2 end end)for s,Z in pairs(Z.DriveSeat:GetChildren())do for s,A in pairs(script:GetChildren())do if Z.Name==A.Name then Z:Stop()wait()Z:Destroy()end end end A:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",Z.DriveSeat,script.Rev.SoundId,0,script.Rev.Volume,true)A:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\118")Z.DriveSeat:WaitForChild("\082\101\118")while wait()do h=math.max(0,h-.1)local I=script.Parent.Values.RPM.Value if script.Parent.Values.Throttle.Value<=M.IdleThrottle/100 then v=math.max(.2,v-.2)E=math.max(0,E-.05)r=1 else v=math.min(.5,v+.1)E=1 r=0 end D=math.min(1,D+.2)if script.Parent.Values.RPM.Value>M.Redline-M.RevBounce/4 and script.Parent.Values.Throttle.Value>M.IdleThrottle/100 then Q=1 else Q=1 end if not Z.DriveSeat.IsOn.Value then H=math.max(H-.015,0)else H=1 end local o=((.35*v)*D)*Q+(((q*r)*E)*(3-v))*math.sin(tick()*50)local R=math.max((script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*I)/M.Redline)*H^2+(u*h)*math.sin(80*tick()),script.Rev.SetPitch.Value)if s then A:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,R,o)else Z.DriveSeat.Rev.Volume=o Z.DriveSeat.Rev.Pitch=R end end

local FE = true
local car = script.Parent.Car.Value
local handler = car:WaitForChild("AC6_FE_Sounds")
local _Tune = require(car["A-Chassis Tune"])
local on = 0
local mult=0
local det=0
local trm=0
local trmmult=0
local trmon=0
local throt=0
local redline=0
local shift=0

script:WaitForChild("Rev")

script.Parent.Values.Gear.Changed:connect(function()
	mult=1
	if script.Parent.Values.RPM.Value>5000 then
		shift=.2
	end
end)

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
	mult=math.max(0,mult-.1)
	local _RPM = script.Parent.Values.RPM.Value
	
	if script.Parent.Values.Throttle.Value <= _Tune.IdleThrottle/100 then
		throt = math.max(.2,throt-.2)
		trmmult = math.max(0,trmmult-.05)
		trmon = 1		
	else
		throt = math.min(.5,throt+.1)
		trmmult = 1
		trmon = 0		
	end	
	shift = math.min(1,shift+.2)	
	if script.Parent.Values.RPM.Value > _Tune.Redline-_Tune.RevBounce/4 and script.Parent.Values.Throttle.Value > _Tune.IdleThrottle/100 then
		redline=1
	else
		redline=1
	end
	
	if not car.DriveSeat.IsOn.Value then on=math.max(on-.015,0) else on=1 end
	local Volume = (.35*throt*shift*redline)+(trm*trmon*trmmult*(3-throt)*math.sin(tick()*50))
	local Pitch = math.max((((script.Rev.SetPitch.Value + script.Rev.SetRev.Value*_RPM/_Tune.Redline))*on^2)+(det*mult*math.sin(80*tick())),script.Rev.SetPitch.Value)
	if FE then
		handler:FireServer("updateSound","Rev",script.Rev.SoundId,Pitch,Volume)
	else
		car.DriveSeat.Rev.Volume = Volume
		car.DriveSeat.Rev.Pitch = Pitch
	end
end
