local c=script.Parent.Parent.Car.Value local g=workspace.FilteringEnabled local o=require(c["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local p=o.Redline local w=WasteGatePressure local R=0 local J=0 local Y=CompressionRatio local y=TurboCount local v=c:WaitForChild("\085\112\100\097\116\101\065\110\100\077\097\107\101")local G=script.Parent.Parent.Values local a=script.Parent.Parent.Values.Throttle.Value local B=1-a local u=1 local q=0 local Q=0 local T=c.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")local L=c.DriveSeat:WaitForChild("\066\079\086")T:Play()script.Parent.Parent.Values.RPM.Changed:connect(function()if G.Horsepower.Value==0 then R=R+(((((G.RPM.Value*(G.Throttle.Value*1.2))/p)/8.5-(R/WasteGatePressure)*(WasteGatePressure/15))*((36/TurboSize)*2))/WasteGatePressure)*15 if R<.05 then R=.05 end if R>2 then R=2 end end if G.Horsepower.Value>0 then R=R+(((((G.Horsepower.Value*(G.Throttle.Value*1.2))/o.Horsepower)/8+(.028-((R/WasteGatePressure)*(WasteGatePressure/15))*1.2))*((36/TurboSize)*2))/WasteGatePressure)*15 if R<.05 then R=.05 end if R>2 then R=2 end end J=R/2 if g then local c=R v:FireServer(R,J,a,B,BOV_Loudness,TurboLoudness,BOV_Pitch)else local g=a local o=c.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")local p=c.DriveSeat:WaitForChild("\066\079\086")local w=p.Volume if g<0 then g=0 end o.Pitch=R o.Volume=(R/4)*TurboLoudness p.Pitch=(1-(-R/20))*BOV_Pitch p.Volume=(-0.5+(R/2)*BOV_Loudness)*(1-script.Parent.Parent.Values.Throttle.Value)end end)

local car = script.Parent.Parent.Car.Value
local FE = workspace.FilteringEnabled
local _Tune = require(car["A-Chassis Tune"])
local Redline = _Tune.Redline
local maxPSI = WasteGatePressure
local totalPSI = 0
local actualPSI = 0
local CR = CompressionRatio
local TC = TurboCount
local handler = car:WaitForChild("UpdateAndMake")
local Values = script.Parent.Parent.Values
local Throttle = script.Parent.Parent.Values.Throttle.Value
local BOVFix = (1 - Throttle)
local tester = 1
local BOVact = 0
local BOVact2 = 0
local Whistle = car.DriveSeat:WaitForChild("Whistle")
local BOV = car.DriveSeat:WaitForChild("BOV")
Whistle:Play()




script.Parent.Parent.Values.RPM.Changed:connect(function()
	--When In Neutral
	if Values.Horsepower.Value == 0 then
		totalPSI = totalPSI + ((((((Values.RPM.Value*(Values.Throttle.Value*1.2)/Redline)/8.5)-(((totalPSI/WasteGatePressure*(WasteGatePressure/15)))))*((36/TurboSize)*2))/WasteGatePressure)*15)
		if totalPSI < 0.05 then
			totalPSI = 0.05
		end
		if totalPSI > 2 then
			totalPSI = 2
		end
		--TEST
		
	end
	--When Driving
	if Values.Horsepower.Value > 0 then
		totalPSI = totalPSI + ((((((Values.Horsepower.Value*(Values.Throttle.Value*1.2)/_Tune.Horsepower)/8)+(0.028-((totalPSI/WasteGatePressure*(WasteGatePressure/15))*1.2)))*((36/TurboSize)*2))/WasteGatePressure)*15)
		if totalPSI < 0.05 then
			totalPSI = 0.05
		end
		if totalPSI > 2 then
			totalPSI = 2
		end
		--TEST
		
	end
	
	
	
	actualPSI = totalPSI/2
	

	if FE then
		local BP = totalPSI
		
		handler:FireServer(totalPSI,actualPSI,Throttle,BOVFix,BOV_Loudness,TurboLoudness,BOV_Pitch)
	else
		local Throttle2 = Throttle
		local W = car.DriveSeat:WaitForChild("Whistle")
		local B = car.DriveSeat:WaitForChild("BOV")

		local bvol = B.Volume		
		
		if Throttle2 < 0 then
			Throttle2 = 0
		end
		W.Pitch = (totalPSI)
		W.Volume = (totalPSI/4)*TurboLoudness
		B.Pitch = (1 - (-totalPSI/20))*BOV_Pitch
		B.Volume = (((-0.5+((totalPSI/2)*BOV_Loudness)))*(1 - script.Parent.Parent.Values.Throttle.Value))
		
	
		
	end
	
end)

