local t=workspace.FilteringEnabled local y=script.Parent.Car.Value local S=y:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local g=require(y["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local W=0 local R=0 local e=1 local Z=.9 local A=.75 script:WaitForChild("\087\104\105\115\116\108\101")script:WaitForChild("\066\079\086")for t,y in pairs(y.DriveSeat:GetChildren())do for t,S in pairs(script:GetChildren())do if y.Name==S.Name then y:Stop()wait()y:Destroy()end end end y.DriveSeat.ChildRemoved:connect(function(t)if t.Name=="\083\101\097\116\087\101\108\100"then for t,y in pairs(y.DriveSeat:GetChildren())do for t,S in pairs(script:GetChildren())do if y.Name==S.Name then y:Stop()wait()y:Destroy()end end end end end)S:FireServer("\110\101\119\083\111\117\110\100","\087\104\105\115\116\108\101",y.DriveSeat,script.Whistle.SoundId,0,script.Whistle.Volume,true)S:FireServer("\110\101\119\083\111\117\110\100","\066\079\086",y.DriveSeat,script.BOV.SoundId,0,script.BOV.Volume,true)S:FireServer("\112\108\097\121\083\111\117\110\100","\087\104\105\115\116\108\101")y.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")y.DriveSeat:WaitForChild("\066\079\086")local P=tick()local f=0 if g.Aspiration=="\083\105\110\103\108\101"then f=1 elseif g.Aspiration=="\068\111\117\098\108\101"then f=2 end while wait()do local b=(script.Parent.Values.Boost.Value/(g.Boost*f))*2 W=math.floor(b*20)WP=b WV=(b/4)*A BP=(1-(-b/20))*Z BV=(-0.5+(b/2)*e)*(1-script.Parent.Values.Throttle.Value)if W<R then if y.DriveSeat.BOV.IsPaused then if t then S:FireServer("\112\108\097\121\083\111\117\110\100","\066\079\086")else y.DriveSeat.BOV:Play()end end end if W>=R then if t then S:FireServer("\115\116\111\112\083\111\117\110\100","\066\079\086")else y.DriveSeat.BOV:Stop()end end if t then S:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\087\104\105\115\116\108\101",script.Whistle.SoundId,WP,WV)S:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\066\079\086",script.BOV.SoundId,BP,BV)else y.DriveSeat.Whistle.Pitch=WP y.DriveSeat.Whistle.Volume=WV y.DriveSeat.BOV.Pitch=BP y.DriveSeat.BOV.Volume=BV end if tick()-P>=.1 then R=math.floor(b*20)P=tick()end end
--[[
	    ___      _______                _       _______
	   / _ |____/ ___/ /  ___ ____ ___ (_)__   /__  __/
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<     / /
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/	/_/   
						SecondLogic @ Inspare
						Avxnturador @ Novena
]]
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 = 1 --volume of the BOV (not exact volume so you kinda have to experiment with it)
local BOV_Pitch = 0.9 --max pitch of the BOV (not exact so might have to mess with it)
local TurboLoudness = 0.75 --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
