local Z=workspace.FilteringEnabled local q=script.Parent.Car.Value local C=q:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local A=require(q["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local G=0 local k=0 local u=0 script:WaitForChild("\084\117\114\098\111")for Z,q in pairs(q.DriveSeat:GetChildren())do for Z,C in pairs(script:GetChildren())do if q.Name==C.Name then q:Stop()wait()q:Destroy()end end end C:FireServer("\110\101\119\083\111\117\110\100","\084\117\114\098\111",q.DriveSeat,script.Turbo.SoundId,0,script.Turbo.Volume,true)C:FireServer("\112\108\097\121\083\111\117\110\100","\084\117\114\098\111")q.DriveSeat:WaitForChild("\084\117\114\098\111")while wait()do local c=script.Parent.Values.RPM.Value local b=script.Parent.Values.Boost.Value if script.Parent.Values.Throttle.Value<=A.IdleThrottle/100 then k=math.max(.3,k-.2)else k=math.min(1,k+.1)end if script.Parent.Values.RPM.Value>A.Redline-A.RevBounce/4 and script.Parent.Values.Throttle.Value>A.IdleThrottle/100 then u=.5 else u=1 end if not script.Parent.IsOn.Value then G=math.max(G-.015,0)else G=1 end local W=math.max((script.Turbo.SetPitch.Value+(script.Turbo.SetRev.Value*c)/A.Redline)*G^2,script.Turbo.SetPitch.Value)if Z then C:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\084\117\114\098\111",script.Turbo.SoundId,W,script.Turbo.Volume)else q.DriveSeat.Turbo.Pitch=W end end
--[[                                              _______     
		___      _______                _        [________)   
	   / _ |____/ ___/ /  ___ ____ ___ (_)__  __   /  /         
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-< /__/ /  /
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/     /__/ 
 						SecondLogic @ Inspare
                       TougeZila @ HomeDepot
]]
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("Turbo")

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", "Turbo", car.DriveSeat, script.Turbo.SoundId, 0, script.Turbo.Volume, true)
handler:FireServer("playSound", "Turbo")
car.DriveSeat:WaitForChild("Turbo")

while wait() do
	local _RPM = script.Parent.Values.RPM.Value
	local _Turbo = script.Parent.Values.Boost.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 script.Parent.IsOn.Value then
		on = math.max(on - 0.015, 0)
	else
		on = 1
	end
	local Pitch = math.max(
		((script.Turbo.SetPitch.Value + script.Turbo.SetRev.Value * _RPM / _Tune.Redline) * on ^ 2),
		script.Turbo.SetPitch.Value
	)
	if FE then
		handler:FireServer("updateSound", "Turbo", script.Turbo.SoundId, Pitch, script.Turbo.Volume)
	else
		car.DriveSeat.Turbo.Pitch = Pitch
	end
end
