local C=script.Parent.Parent.Car.Value local F=workspace.FilteringEnabled local l=require(C["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local B=l.Redline local h=WasteGatePressure local K=0 local y=0 local R=CompressionRatio local c=TurboCount local o=C:WaitForChild("\085\112\100\097\116\101\065\110\100\077\097\107\101")local G=script.Parent.Parent.Values local U=script.Parent.Parent.Values.Throttle.Value local P=1-U local e=1 local Y=0 local b=0 local u=C.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")local m=C.DriveSeat:WaitForChild("\066\079\086")u:Play()script.Parent.Parent.Values.RPM.Changed:connect(function()if G.Horsepower.Value==0 then K=K+(((((G.RPM.Value*(G.Throttle.Value*1.2))/B)/9-.035)*((36/TurboSize)*2))/WasteGatePressure)*15 if K<.05 then K=.05 end if K>2 then K=2 end end if G.Horsepower.Value>0 then K=K+(((((G.Horsepower.Value*(G.Throttle.Value*1.2))/l.Horsepower)/9-.045)*((36/TurboSize)*2))/WasteGatePressure)*15 if K<.05 then K=.05 end if K>2 then K=2 end end y=K/2 if F then local C=K o:FireServer(K,y,U,P,BOV_Loudness,TurboLoudness)else local F=U local l=C.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")local B=C.DriveSeat:WaitForChild("\066\079\086")if F<0 then F=0 end l.Pitch=K l.Volume=(K/4)*TurboLoudness B.Pitch=1-(-K/40)B.Volume=(((-0.03+K/2)*(1-U))/2)*BOV_Loudness 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.035)*((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)/9)-0.045)*((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)
	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)*TurboLoudness
		B.Pitch = 1 - (-totalPSI/40)
		B.Volume = (((-0.03+totalPSI/2)*(1 - Throttle))/2)*BOV_Loudness
		
	end
	
end)

