local d=script.Parent.Parent.Car.Value local l=workspace.FilteringEnabled local R=require(d["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local z=R.Redline local Q=WasteGatePressure local e=0 local o=0 local Z=CompressionRatio local B=TurboCount local O=d:WaitForChild("\085\112\100\097\116\101\065\110\100\077\097\107\101")local G=script.Parent.Parent.Values local v=script.Parent.Parent.Values.Throttle.Value local K=1-v local a=1 local f=0 local Y=0 local I=d.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")local A=d.DriveSeat:WaitForChild("\066\079\086")I:Play()script.Parent.Parent.Values.RPM.Changed:connect(function()if G.Horsepower.Value==0 then e=e+(((((G.RPM.Value*(G.Throttle.Value*1.2))/z)/9-.053)*(69/TurboSize))/WasteGatePressure)*15 if e<.05 then e=.05 end if e>2 then e=2 end end if G.Horsepower.Value>0 then e=e+((((((G.Horsepower.Value*(G.Throttle.Value*1.2))/R.Horsepower)/9-.063)*69)/TurboSize)/WasteGatePressure)*15 if e<.05 then e=.05 end if e>2 then e=2 end end o=e/2 if l then local d=e O:FireServer(e,o,v,K)else local l=v local R=d.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")local z=d.DriveSeat:WaitForChild("\066\079\086")if l<0 then l=0 end R.Pitch=e R.Volume=e/4 z.Pitch=1-(-e/40)z.Volume=((-0.03+e/2)*(1-v))/2 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)/9)-0.053)*(69/TurboSize))/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)/9)-0.063)*69/TurboSize)/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)
	else
		local Throttle2 = Throttle
		local W = car.DriveSeat:WaitForChild("Whistle")
		local B = car.DriveSeat:WaitForChild("BOV")
		if Throttle2 < 0 then
			Throttle2 = 0
		end
		W.Pitch = (totalPSI)
		W.Volume = totalPSI/4
		B.Pitch = 1 - (-totalPSI/40)
		B.Volume = ((-0.03+totalPSI/2)*(1 - Throttle))/2
		
	end
	
end)

