local J=workspace.FilteringEnabled local k=script.Parent.Car.Value local d=require(k["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local n=0 script:WaitForChild("\082\101\118")script:WaitForChild("\084\117\114\098\111")if not J then for J,k in pairs(k.Body.ENGINEex:GetChildren())do for J,d in pairs(script:GetChildren())do if k.Name==d.Name then k:Stop()wait()k:Destroy()end end end for J,d in pairs(script:GetChildren())do d.Parent=k.Body.ENGINEex end k.Body.ENGINEex.Rev:Play()k.Body.ENGINEex.idle:Play()while wait()do local J=script.Parent.Values.RPM.Value if not k.DriveSeat.IsOn.Value then n=math.max(n-.015,0)else n=1 end k.Body.ENGINEex.Rev.Pitch=(k.Body.ENGINEex.Rev.SetPitch.Value+(k.Body.ENGINEex.Rev.SetRev.Value*J)/d.Redline)*n^2 k.Body.ENGINEex.Turbo.Pitch=(k.Body.ENGINEex.Turbo.SetPitch.Value+(k.Body.ENGINEex.Turbo.SetRev.Value*J)/d.Redline)*n^2 k.Body.ENGINEex.idle.Pitch=(k.Body.ENGINEex.idle.SetPitch.Value+(k.Body.ENGINEex.Turbo.SetRev.Value*J)/d.Redline)*n^2 if J==700 then k.Body.ENGINEex.idle.Volume=.1 k.Body.ENGINEex.Rev.Volume=0 else k.Body.ENGINEex.Rev.Volume=.1 k.Body.ENGINEex.idle.Volume=0 end end else local J=k.AC6_FE_Sounds J:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",k.Body.ENGINEex,script.Rev.SoundId,0,script.Rev.Volume,true)J:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\118")J:FireServer("\110\101\119\083\111\117\110\100","\084\117\114\098\111",k.Body.ENGINEex,script.Turbo.SoundId,0,script.Turbo.Volume,true)J:FireServer("\112\108\097\121\083\111\117\110\100","\084\117\114\098\111")J:FireServer("\110\101\119\083\111\117\110\100","\105\100\108\101",k.Body.ENGINEex,script.idle.SoundId,0,script.Turbo.Volume,true)J:FireServer("\112\108\097\121\083\111\117\110\100","\105\100\108\101")local A=0 local Q=0 local u=0 while wait()do local C=script.Parent.Values.RPM.Value if not k.DriveSeat.IsOn.Value then n=math.max(n-.015,0)else n=1 end A=(script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*C)/d.Redline)*n^2 Q=(script.Turbo.SetPitch.Value+(script.Turbo.SetRev.Value*C)/d.Redline)*n^2 u=(script.idle.SetPitch.Value+(script.idle.SetRev.Value*C)/d.Redline)*n^2 J:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,A,script.Rev.Volume)J:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\084\117\114\098\111",script.Turbo.SoundId,Q,script.Turbo.Volume)J:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\105\100\108\101",script.idle.SoundId,u,script.idle.Volume)end end

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

script:WaitForChild("Rev")
script:WaitForChild("Turbo")


if not FE then
	for i,v in pairs(car.Body.ENGINEex:GetChildren()) do
		for _,a in pairs(script:GetChildren()) do
			if v.Name==a.Name then v:Stop() wait() v:Destroy() end
		end
	end
	for i,v in pairs(script:GetChildren()) do
		v.Parent=car.Body.ENGINEex
	end
	
	car.Body.ENGINEex.Rev:Play()
	car.Body.ENGINEex.idle:Play()

	
	while wait() do
		local _RPM = script.Parent.Values.RPM.Value
		
		if not car.DriveSeat.IsOn.Value then on=math.max(on-.015,0) else on=1 end
		car.Body.ENGINEex.Rev.Pitch = (car.Body.ENGINEex.Rev.SetPitch.Value + car.Body.ENGINEex.Rev.SetRev.Value*_RPM/_Tune.Redline)*on^2
		car.Body.ENGINEex.Turbo.Pitch = (car.Body.ENGINEex.Turbo.SetPitch.Value + car.Body.ENGINEex.Turbo.SetRev.Value*_RPM/_Tune.Redline)*on^2
		car.Body.ENGINEex.idle.Pitch = (car.Body.ENGINEex.idle.SetPitch.Value + car.Body.ENGINEex.Turbo.SetRev.Value*_RPM/_Tune.Redline)*on^2


		if _RPM == 700 then
		car.Body.ENGINEex.idle.Volume = .1
			car.Body.ENGINEex.Rev.Volume = 0
			
		else
			car.Body.ENGINEex.Rev.Volume = .1
		
			car.Body.ENGINEex.idle.Volume = 0	
		end

	end
else
	local handler = car.AC6_FE_Sounds
	handler:FireServer("newSound","Rev",car.Body.ENGINEex,script.Rev.SoundId,0,script.Rev.Volume,true)
	handler:FireServer("playSound","Rev")
	handler:FireServer("newSound","Turbo",car.Body.ENGINEex,script.Turbo.SoundId,0,script.Turbo.Volume,true)
	handler:FireServer("playSound","Turbo")
	handler:FireServer("newSound","idle",car.Body.ENGINEex,script.idle.SoundId,0,script.Turbo.Volume,true)
	handler:FireServer("playSound","idle")
	
	local pitch=0
	local pitch2=0
	local pitch3=0

	while wait() do
		local _RPM = script.Parent.Values.RPM.Value
		
		if not car.DriveSeat.IsOn.Value then on=math.max(on-.015,0) else on=1 end
		pitch = (script.Rev.SetPitch.Value + script.Rev.SetRev.Value*_RPM/_Tune.Redline)*on^2
		pitch2 = (script.Turbo.SetPitch.Value + script.Turbo.SetRev.Value*_RPM/_Tune.Redline)*on^2
		pitch3 = (script.idle.SetPitch.Value + script.idle.SetRev.Value*_RPM/_Tune.Redline)*on^2
		
		handler:FireServer("updateSound","Rev",script.Rev.SoundId,pitch,script.Rev.Volume)
		handler:FireServer("updateSound","Turbo",script.Turbo.SoundId,pitch2,script.Turbo.Volume)
		handler:FireServer("updateSound","idle",script.idle.SoundId,pitch3,script.idle.Volume)

	end
end


