local t=workspace.FilteringEnabled local o=script.Parent.Car.Value local n=o:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115")local P=require(o["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local b=0 local d=0 local M=5 local h=1 local I=2 script:WaitForChild("\087\104\105\115\116\108\101")script:WaitForChild("\066\079\086")for t,o in pairs(o.DriveSeat:GetChildren())do for t,n in pairs(script:GetChildren())do if o.Name==n.Name then o:Stop()wait()o:Destroy()end end end o.DriveSeat.ChildRemoved:connect(function(t)if t.Name=="\083\101\097\116\087\101\108\100"then for t,o in pairs(o.DriveSeat:GetChildren())do for t,n in pairs(script:GetChildren())do if o.Name==n.Name then o:Stop()wait()o:Destroy()end end end end end)n:FireServer("\110\101\119\083\111\117\110\100","\087\104\105\115\116\108\101",o.DriveSeat,script.Whistle.SoundId,0,script.Whistle.Volume,true)n:FireServer("\110\101\119\083\111\117\110\100","\066\079\086",o.DriveSeat,script.BOV.SoundId,0,script.BOV.Volume,true)n:FireServer("\112\108\097\121\083\111\117\110\100","\087\104\105\115\116\108\101")o.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")o.DriveSeat:WaitForChild("\066\079\086")local E=tick()local u=0 if P.Aspiration=="\083\105\110\103\108\101"then u=1 elseif P.Aspiration=="\068\111\117\098\108\101"then u=2 end while wait()do local H=(script.Parent.Values.Boost.Value/(P.Boost*u))*2 b=math.floor(H*20)WP=H WV=(H/4)*I BP=(1-(-H/20))*h BV=(-0.5+(H/2)*M)*(1-script.Parent.Values.Throttle.Value)if b<d then if o.DriveSeat.BOV.IsPaused then if t then n:FireServer("\112\108\097\121\083\111\117\110\100","\066\079\086")else o.DriveSeat.BOV:Play()end end end if b>=d then if t then n:FireServer("\115\116\111\112\083\111\117\110\100","\066\079\086")else o.DriveSeat.BOV:Stop()end end if t then n:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\087\104\105\115\116\108\101",script.Whistle.SoundId,WP,WV)n:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\066\079\086",script.BOV.SoundId,BP,BV)else o.DriveSeat.Whistle.Pitch=WP o.DriveSeat.Whistle.Volume=WV o.DriveSeat.BOV.Pitch=BP o.DriveSeat.BOV.Volume=BV end if tick()-E>=.1 then d=math.floor(H*20)E=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 = 5 --volume of the BOV (not exact volume so you kinda have to experiment with it)
local BOV_Pitch = 1 --max pitch of the BOV (not exact so might have to mess with it)
local TurboLoudness = 2 --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
