local z=workspace.FilteringEnabled local T=script.Parent.Car.Value local f=require(T["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local X=0 script:WaitForChild("\082\101\118")script:WaitForChild("\084\117\114\098\111")if not z then for z,T in pairs(T.Body.ENGINE:GetChildren())do for z,f in pairs(script:GetChildren())do if T.Name==f.Name then T:Stop()wait()T:Destroy()end end end for z,f in pairs(script:GetChildren())do f.Parent=T.Body.ENGINE end T.Body.ENGINE.Rev:Play()T.Body.ENGINE.idle:Play()while wait()do local z=script.Parent.Values.RPM.Value if not T.DriveSeat.IsOn.Value then X=math.max(X-.015,0)else X=1 end T.Body.ENGINE.Rev.Pitch=(T.Body.ENGINE.Rev.SetPitch.Value+(T.Body.ENGINE.Rev.SetRev.Value*z)/f.Redline)*X^2 T.Body.ENGINE.Turbo.Pitch=(T.Body.ENGINE.Turbo.SetPitch.Value+(T.Body.ENGINE.Turbo.SetRev.Value*z)/f.Redline)*X^2 T.Body.ENGINE.idle.Pitch=(T.Body.ENGINE.idle.SetPitch.Value+(T.Body.ENGINE.Turbo.SetRev.Value*z)/f.Redline)*X^2 if z==700 then T.Body.ENGINE.idle.Volume=.1 T.Body.ENGINE.Turbo.Volume=.2 T.Body.ENGINE.Rev.Volume=0 else T.Body.ENGINE.Rev.Volume=.2 T.Body.ENGINE.idle.Volume=0 end end else local z=T.AC6_FE_Sounds z:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",T.Body.ENGINE,script.Rev.SoundId,0,script.Rev.Volume,true)z:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\118")z:FireServer("\110\101\119\083\111\117\110\100","\084\117\114\098\111",T.Body.ENGINE,script.Turbo.SoundId,0,script.Turbo.Volume,true)z:FireServer("\112\108\097\121\083\111\117\110\100","\084\117\114\098\111")z:FireServer("\110\101\119\083\111\117\110\100","\105\100\108\101",T.Body.ENGINE,script.idle.SoundId,0,script.Turbo.Volume,true)z:FireServer("\112\108\097\121\083\111\117\110\100","\105\100\108\101")local Y=0 local s=0 local x=0 while wait()do local E=script.Parent.Values.RPM.Value if not T.DriveSeat.IsOn.Value then X=math.max(X-.015,0)else X=1 end Y=(script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*E)/f.Redline)*X^2 s=(script.Turbo.SetPitch.Value+(script.Turbo.SetRev.Value*E)/f.Redline)*X^2 x=(script.idle.SetPitch.Value+(script.idle.SetRev.Value*E)/f.Redline)*X^2 z:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,Y,script.Rev.Volume)z:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\084\117\114\098\111",script.Turbo.SoundId,s,script.Turbo.Volume)z:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\105\100\108\101",script.idle.SoundId,x,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.ENGINE: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.ENGINE
	end
	
	car.Body.ENGINE.Rev:Play()
	car.Body.ENGINE.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.ENGINE.Rev.Pitch = (car.Body.ENGINE.Rev.SetPitch.Value + car.Body.ENGINE.Rev.SetRev.Value*_RPM/_Tune.Redline)*on^2
		car.Body.ENGINE.Turbo.Pitch = (car.Body.ENGINE.Turbo.SetPitch.Value + car.Body.ENGINE.Turbo.SetRev.Value*_RPM/_Tune.Redline)*on^2
		car.Body.ENGINE.idle.Pitch = (car.Body.ENGINE.idle.SetPitch.Value + car.Body.ENGINE.Turbo.SetRev.Value*_RPM/_Tune.Redline)*on^2

		if _RPM == 700 then
		car.Body.ENGINE.idle.Volume = .1-- 0/.07
		car.Body.ENGINE.Turbo.Volume = .2
			car.Body.ENGINE.Rev.Volume = 0
			
		else
			car.Body.ENGINE.Rev.Volume = .2
			car.Body.ENGINE.idle.Volume = 0	
		--	car.Body.ENGINE.Turbo:Stop()	
		end
		
		
	
	
	end
else
	local handler = car.AC6_FE_Sounds
	handler:FireServer("newSound","Rev",car.Body.ENGINE,script.Rev.SoundId,0,script.Rev.Volume,true)
	handler:FireServer("playSound","Rev")
	handler:FireServer("newSound","Turbo",car.Body.ENGINE,script.Turbo.SoundId,0,script.Turbo.Volume,true)
	handler:FireServer("playSound","Turbo")
	handler:FireServer("newSound","idle",car.Body.ENGINE,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


