local Z=workspace.FilteringEnabled local Q=script.Parent.Car.Value local A=require(Q["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local F=0 script:WaitForChild("\082\101\118")script:WaitForChild("\084\117\114\098\111")if not Z then for Z,Q in pairs(Q.Body.ENGINEex:GetChildren())do for Z,A in pairs(script:GetChildren())do if Q.Name==A.Name then Q:Stop()wait()Q:Destroy()end end end for Z,A in pairs(script:GetChildren())do A.Parent=Q.Body.ENGINEex end Q.Body.ENGINEex.Rev:Play()Q.Body.ENGINEex.idle:Play()while wait()do local Z=script.Parent.Values.RPM.Value if not Q.DriveSeat.IsOn.Value then F=math.max(F-.015,0)else F=1 end Q.Body.ENGINEex.Rev.Pitch=(Q.Body.ENGINEex.Rev.SetPitch.Value+(Q.Body.ENGINEex.Rev.SetRev.Value*Z)/A.Redline)*F^2 Q.Body.ENGINEex.Turbo.Pitch=(Q.Body.ENGINEex.Turbo.SetPitch.Value+(Q.Body.ENGINEex.Turbo.SetRev.Value*Z)/A.Redline)*F^2 Q.Body.ENGINEex.idle.Pitch=(Q.Body.ENGINEex.idle.SetPitch.Value+(Q.Body.ENGINEex.Turbo.SetRev.Value*Z)/A.Redline)*F^2 if Z==700 then Q.Body.ENGINEex.idle.Volume=.1 Q.Body.ENGINEex.Rev.Volume=0 else Q.Body.ENGINEex.Rev.Volume=.1 Q.Body.ENGINEex.idle.Volume=0 end end else local Z=Q.AC6_FE_Sounds Z:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",Q.Body.ENGINEex,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",Q.Body.ENGINEex,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",Q.Body.ENGINEex,script.idle.SoundId,0,script.Turbo.Volume,true)Z:FireServer("\112\108\097\121\083\111\117\110\100","\105\100\108\101")local b=0 local q=0 local U=0 while wait()do local N=script.Parent.Values.RPM.Value if not Q.DriveSeat.IsOn.Value then F=math.max(F-.015,0)else F=1 end b=(script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*N)/A.Redline)*F^2 q=(script.Turbo.SetPitch.Value+(script.Turbo.SetRev.Value*N)/A.Redline)*F^2 U=(script.idle.SetPitch.Value+(script.idle.SetRev.Value*N)/A.Redline)*F^2 Z:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,b,script.Rev.Volume)Z:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\084\117\114\098\111",script.Turbo.SoundId,q,script.Turbo.Volume)Z: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
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						SecondLogic @ Inspare
]]
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 - 0.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 = 0.1
			car.Body.ENGINEex.Rev.Volume = 0
		else
			car.Body.ENGINEex.Rev.Volume = 0.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 - 0.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
