local K=workspace.FilteringEnabled local h=script.Parent.Car.Value local R=h:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local V=require(h["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local m=0 local B=0 local d=0 local p=.2 local Q=0 script:WaitForChild("\087\104\105\115\116\108\101")script:WaitForChild("\066\079\086")for K,h in pairs(h.DriveSeat:GetChildren())do for K,R in pairs(script:GetChildren())do if h.Name==R.Name then h:Stop()wait()h:Destroy()end end end h.DriveSeat.ChildRemoved:connect(function(K)if K.Name=="\083\101\097\116\087\101\108\100"then for K,h in pairs(h.DriveSeat:GetChildren())do for K,R in pairs(script:GetChildren())do if h.Name==R.Name then h:Stop()wait()h:Destroy()end end end end end)R:FireServer("\110\101\119\083\111\117\110\100","\087\104\105\115\116\108\101",h.DriveSeat,script.Whistle.SoundId,0,script.Whistle.Volume,true)R:FireServer("\110\101\119\083\111\117\110\100","\066\079\086",h.DriveSeat,script.BOV.SoundId,0,script.BOV.Volume,true)R:FireServer("\112\108\097\121\083\111\117\110\100","\087\104\105\115\116\108\101")h.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")h.DriveSeat:WaitForChild("\066\079\086")local e=tick()local Z=0 if V.Aspiration=="\083\105\110\103\108\101"then Z=1 elseif V.Aspiration=="\068\111\117\098\108\101"then Z=2 end while wait()do local r=(script.Parent.Values.Boost.Value/(V.Boost*Z))*2 m=math.floor(r*20)WP=r WV=(r/4)*Q BP=(1-(-r/20))*p BV=(-0.5+(r/2)*d)*(1-script.Parent.Values.Throttle.Value)if m<B then if h.DriveSeat.BOV.IsPaused then if K then R:FireServer("\112\108\097\121\083\111\117\110\100","\066\079\086")else h.DriveSeat.BOV:Play()end end end if m>=B then if K then R:FireServer("\115\116\111\112\083\111\117\110\100","\066\079\086")else h.DriveSeat.BOV:Stop()end end if K then R:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\087\104\105\115\116\108\101",script.Whistle.SoundId,WP,WV)R:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\066\079\086",script.BOV.SoundId,BP,BV)else h.DriveSeat.Whistle.Pitch=WP h.DriveSeat.Whistle.Volume=WV h.DriveSeat.BOV.Pitch=BP h.DriveSeat.BOV.Volume=BV end if tick()-e>=.1 then B=math.floor(r*20)e=tick()end end

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 BOVact = 0
local BOVact2 = 0

local BOV_Loudness = 0	--volume of the BOV (not exact volume so you kinda have to experiment with it)
local BOV_Pitch = 0.2	--max pitch of the BOV (not exact so might have to mess with it)
local TurboLoudness = 0 --volume of the Turbo (not exact volume so you kinda have to experiment with it also)

script:WaitForChild("Whistle")
script:WaitForChild("BOV")

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

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name=="SeatWeld" then
		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
	end
end)

handler:FireServer("newSound","Whistle",car.DriveSeat,script.Whistle.SoundId,0,script.Whistle.Volume,true)
handler:FireServer("newSound","BOV",car.DriveSeat,script.BOV.SoundId,0,script.BOV.Volume,true)
handler:FireServer("playSound","Whistle")
car.DriveSeat:WaitForChild("Whistle")
car.DriveSeat:WaitForChild("BOV")
local ticc = tick()
local _TCount = 0
if _Tune.Aspiration == "Single" then _TCount = 1 elseif _Tune.Aspiration == "Double" then _TCount = 2 end

while wait() do
	local psi = (((script.Parent.Values.Boost.Value)/(_Tune.Boost*_TCount))*2)
	
	BOVact = math.floor(psi*20)
	WP = (psi)
	WV = (psi/4)*TurboLoudness
	
	BP = (1-(-psi/20))*BOV_Pitch
	BV = (((-0.5+((psi/2)*BOV_Loudness)))*(1 - script.Parent.Values.Throttle.Value))

	if BOVact < BOVact2 then if car.DriveSeat.BOV.IsPaused then if FE then handler:FireServer("playSound","BOV") else car.DriveSeat.BOV:Play() end end end
	if BOVact >= BOVact2 then if FE then handler:FireServer("stopSound","BOV") else car.DriveSeat.BOV:Stop() end end
	
	if FE then
		handler:FireServer("updateSound","Whistle",script.Whistle.SoundId,WP,WV)
		handler:FireServer("updateSound","BOV",script.BOV.SoundId,BP,BV)
	else
		car.DriveSeat.Whistle.Pitch = WP
		car.DriveSeat.Whistle.Volume = WV
		car.DriveSeat.BOV.Pitch = BP
		car.DriveSeat.BOV.Volume = BV
	end
	if (tick()-ticc) >= 0.1 then
		BOVact2 = math.floor(psi*20)
		ticc = tick()
	end
end
