local m=workspace.FilteringEnabled local S=script.Parent.Car.Value local P=S:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local j=require(S["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local U=0 local l=0 local x=0 script:WaitForChild("\082\101\118")for m,S in pairs(S.DriveSeat:GetChildren())do for m,P in pairs(script:GetChildren())do if S.Name==P.Name then S:Stop()wait()S:Destroy()end end end P:FireServer("\110\101\119\083\111\117\110\100","\082\101\118",S.DriveSeat,script.Rev.SoundId,0,script.Rev.Volume,true)P:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\118")S.DriveSeat:WaitForChild("\082\101\118")while wait()do local d=script.Parent.Values.RPM.Value if script.Parent.Values.Throttle.Value<=j.IdleThrottle/100 then l=math.max(.3,l-.2)else l=math.min(1,l+.1)end if script.Parent.Values.RPM.Value>j.Redline-j.RevBounce/4 and script.Parent.Values.Throttle.Value>j.IdleThrottle/100 then x=.5 else x=1 end if not S.DriveSeat.IsOn.Value then U=math.max(U-.015,0)else U=1 end local t=math.max((script.Rev.SetPitch.Value+(script.Rev.SetRev.Value*d)/j.Redline)*U^2,script.Rev.SetPitch.Value)if m then P:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\118",script.Rev.SoundId,t,script.Rev.Volume)else S.DriveSeat.Rev.Pitch=t end end
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						SecondLogic @ Inspare
]]
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(0.3, throt - 0.2)
	else
		throt = math.min(1, throt + 0.1)
	end
	if
		script.Parent.Values.RPM.Value > _Tune.Redline - _Tune.RevBounce / 4
		and script.Parent.Values.Throttle.Value > _Tune.IdleThrottle / 100
	then
		redline = 0.5
	else
		redline = 1
	end
	if not car.DriveSeat.IsOn.Value then
		on = math.max(on - 0.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
