--notes
--rpm = 11000 / 100000 = 0.1, rpm = 1000 / 100000 = 0.01 * 4 = 0.04

Values.Values.RPM.Changed:connect(function()
	Throttle = Values.Values.Throttle.Value
	CurrentGear = Values.Values.Gear.Value
	CurrentRPM = Values.Values.RPM.Value
	if Throttle == 1 then
		active = true
		if CPSI < PSI then 
			if Turbos == "Single" then
				if TurboSize == "Small" then
					CPSI = CPSI + (CurrentRPM / 75000) * 4
					wait(0.1)
					Values.Values.PSI.Value = CPSI * 8
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Medium" then
					CPSI = CPSI + (CurrentRPM / 100000) * 4
					wait(0.1)
					Values.Values.PSI.Value = CPSI * 10
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Large" then
					CPSI = CPSI + (CurrentRPM / 125000) * 4
					wait(0.1)
					Values.Values.PSI.Value = CPSI * 12
					Values.Values.APSI.Value = CPSI
				end
			elseif Turbos == "Twin" then
				if TurboSize == "Small" then
					CPSI = CPSI + (CurrentRPM / 75000) * 4
					wait(0.05)
					Values.Values.PSI.Value = CPSI * 8
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Medium" then
					CPSI = CPSI + (CurrentRPM / 100000) * 4
					wait(0.05)
					Values.Values.PSI.Value = CPSI * 10
					Values.Values.APSI.Value = CPSI
				end
				if TurboSize == "Large" then
					CPSI = CPSI + (CurrentRPM / 125000) * 4
					wait(0.05)
					Values.Values.PSI.Value = CPSI * 12
					Values.Values.APSI.Value = CPSI
				end	
			end
		end
		if CurrentRPM > (_Tune.Redline - 500) and TwoStep == true and boom == true  then
			boom = false
				if car.Body.Exhaust.E1.S.IsPlaying then
				else
				local i = math.random(1,4)
				i = math.ceil(i)
				while i >= 1 do
				car.Body.Exhaust.E2.S:Play()
				car.Body.Exhaust.E1.Afterburn.Enabled = true
				car.Body.Exhaust.E2.Afterburn.Enabled = true
				wait(math.random(0.2,.3))
				car.Body.Exhaust.E1.Afterburn.Enabled = false
				car.Body.Exhaust.E2.Afterburn.Enabled = false
				i= i - 1
				end
				wait(0.5)
				boom = true
				end
				end
	end
			if Throttle <= 0.01 and active == true and Valve == "BOV" then
				active = false
				CPSI = 0
				if TurboSize == "Large" then
					Values.Values.PSI.Value = CPSI * 12
				elseif TurboSize == "Medium" then
					Values.Values.PSI.Value = CPSI * 10
				elseif TurboSize == "Small" then
					Values.Values.PSI.Value = CPSI * 8
				end	
				Values.Values.APSI.Value = CPSI
				if BOV.IsPlaying then		
				else
				BOV:Play()
				end
			end
			if Throttle <= 0.01 and Valve == "Bleed" then
				if CPSI > 0 then
				CPSI = CPSI - 0.1
				wait(0.05)
				end
				if TurboSize == "Large" then
					Values.Values.PSI.Value = CPSI * 12
				elseif TurboSize == "Medium" then
					Values.Values.PSI.Value = CPSI * 10
				elseif TurboSize == "Small" then
					Values.Values.PSI.Value = CPSI * 8
				end				
				Values.Values.APSI.Value = CPSI
				if active == true then
				if BOV.IsPlaying then		
				else
				BOV:Play()
				active = false
				end
				end
			end
		end
)
if boom == false then wait(math.random(1)) boom = true end
