local U=_Tune.FinalDrive*_Tune.FDMult local o=(U*30)/math.pi local N=(workspace.Gravity*_Tune.InclineComp)/32.2 local q=(wDia*math.pi)/60 local R=CFrame.Angles(math.pi/2,-math.pi/2,0)local y=CFrame.Angles(0,math.pi,0)local G=.70710678118655 if _Tune.Aspiration=="\083\105\110\103\108\101"then _TCount=1 _TPsi=_Tune.Boost elseif _Tune.Aspiration=="\068\111\117\098\108\101"then _TCount=2 _TPsi=_Tune.Boost*2 end local c=_Tune.Horsepower/100 local E=(((_Tune.Horsepower*(_TPsi*(_Tune.CompressRatio/10)))/7.5)/2)/100 local b=_Tune.PeakRPM/1000 local Z=_Tune.PeakSharpness local a=_Tune.CurveMult local Y=_Tune.EqPoint/1000 function curveHP(U)U=U/1000 return(-(U-b)^2*math.min(c/b^2,a^(b/c))+c)*(U-U^Z/(Z*b^(Z-1)))end local I=curveHP(_Tune.PeakRPM)function curvePSI(U)U=U/1000 return(-(U-b)^2*math.min(E/b^2,a^(b/E))+E)*(U-U^Z/(Z*b^(Z-1)))end local B=curvePSI(_Tune.PeakRPM)function GetCurve(o,N)local q=math.max(curveHP(o)/(I/c),0)*100 return q,((((q*(Y/o))*_Tune.Ratios[N+2])*U)*hpScaling)*1000 end function GetPsiCurve(o,N)local q=math.max(curvePSI(o)/(B/E),0)*100 return q,((((q*(Y/o))*_Tune.Ratios[N+2])*U)*hpScaling)*1000 end local e={}local k={}for U,o in pairs(_Tune.Ratios)do local N={}local q={}for o=math.floor(_Tune.IdleRPM/100),math.ceil((_Tune.Redline+100)/100),1 do local R={}local y={}R.Horsepower,R.Torque=GetCurve(o*100,U-2)y.Horsepower,y.Torque=GetPsiCurve(o*100,U-2)hp1,tq1=GetCurve((o+1)*100,U-2)hp2,tq2=GetPsiCurve((o+1)*100,U-2)R.HpSlope=hp1-R.Horsepower y.HpSlope=hp2-y.Horsepower R.TqSlope=tq1-R.Torque y.TqSlope=tq2-y.Torque N[o]=R q[o]=y end table.insert(e,N)table.insert(k,q)end wait()function Auto()local N=0 for U,o in pairs(Drive)do if o.RotVelocity.Magnitude>N then N=o.RotVelocity.Magnitude end end if _IsOn then _ClutchOn=true if _CGear>=1 then if _GBrake>0 and car.DriveSeat.Velocity.Magnitude<5 then _CGear=1 else if _Tune.AutoShiftMode=="\082\080\077"then if _RPM>_Tune.PeakRPM+_Tune.AutoUpThresh then if _CGear~=0 and _CGear~=#_Tune.Ratios-2 then _GThrotShift=0 wait(_Tune.ShiftTime)_GThrotShift=1 end _CGear=math.min(_CGear+1,#_Tune.Ratios-2)elseif math.max(math.min((N*_Tune.Ratios[_CGear+1])*o,_Tune.Redline+100),_Tune.IdleRPM)<_Tune.PeakRPM-_Tune.AutoDownThresh then if _CGear~=1 then _GThrotShift=0 wait(_Tune.ShiftTime/2)_GThrotShift=1 end _CGear=math.max(_CGear-1,1)end else if car.DriveSeat.Velocity.Magnitude>math.ceil(((q*(_Tune.PeakRPM+_Tune.AutoUpThresh))/_Tune.Ratios[_CGear+2])/U)then if _CGear~=0 and _CGear~=#_Tune.Ratios-2 then _GThrotShift=0 wait(_Tune.ShiftTime)_GThrotShift=1 end _CGear=math.min(_CGear+1,#_Tune.Ratios-2)elseif car.DriveSeat.Velocity.Magnitude<math.ceil(((q*(_Tune.PeakRPM-_Tune.AutoDownThresh))/_Tune.Ratios[_CGear+1])/U)then if _CGear~=1 then _GThrotShift=0 wait(_Tune.ShiftTime/2)_GThrotShift=1 end _CGear=math.max(_CGear-1,1)end end end end end end local g=1 function Engine()if _CGear==0 then _ClutchOn=false end local U=_Tune.IdleRPM if not _IsOn then U=0 _CGear=0 _ClutchOn=false _GThrot=_Tune.IdleThrottle/100 end local q=0 local c=0 for U,o in pairs(Drive)do q=q+o.RotVelocity.Magnitude c=c+1 end q=q/c if _ClutchOn then if _Tune.DriveTransfer=="\084\111\114\113\117\101\067\111\110\118\101\114\116\101\114"then local N=math.max(math.min((q*_Tune.Ratios[_CGear+2])*o,_Tune.Redline+100),U)+(((_Tune.TConverter+800)*_GThrot-_Tune.IdleRPM*_GThrot)-38*_Tune.IdleThrottle)local R=math.min(math.abs((N-((_Tune.TConverter-1000)*(_RPM/_Tune.Redline))*_GThrot)-_RPM)/_Tune.ClutchTol,.97)_RPM=_RPM*R+(N-((_Tune.TConverter-1000)*(_RPM/_Tune.Redline))*_GThrot)*(1-R)end if _Tune.DriveTransfer=="\067\108\117\116\099\104"then local N=math.max(math.min((q*_Tune.Ratios[_CGear+2])*o,_Tune.Redline+100),U)local R=math.min(math.abs(N-_RPM)/_Tune.ClutchTol,.9)_RPM=_RPM*R+N*(1-R)end else if _GThrot-_Tune.IdleThrottle/100>0 then if _RPM>_Tune.Redline then _RPM=_RPM-_Tune.RevBounce*2 else _RPM=math.min(_RPM+(_Tune.RevAccel*(script.Parent.Values.RPM.Value/_Tune.Redline))*_GThrot,_Tune.Redline+100)end else _RPM=math.max(_RPM-_Tune.RevDecay*(script.Parent.Values.RPM.Value/_Tune.Redline),U)end end _spLimit=(_Tune.Redline+100)/(o*_Tune.Ratios[_CGear+2])if _RPM>_Tune.Redline then if _CGear<#_Tune.Ratios-2 then _RPM=_RPM-_Tune.RevBounce else _RPM=_RPM-_Tune.RevBounce*.5 end end local E=_TPsi/_TCount _Boost=_Boost+(((((_HP*(_GThrot*1.2))/_Tune.Horsepower)/8-(_Boost/E)*(E/15))*((8/_Tune.TurboSize)*(1+_Boost*2)))/E)*15 if _Boost<.05 then _Boost=.05 elseif _Boost>2 then _Boost=2 end local b=e[_CGear+2][math.floor(math.min(_Tune.Redline,math.max(_Tune.IdleRPM,_RPM))/100)]_NH=b.Horsepower+(b.HpSlope*((_RPM-math.floor(_RPM/100))/1000))%1 _NT=b.Torque+(b.TqSlope*((_RPM-math.floor(_RPM/100))/1000))%1 if _Tune.Aspiration~="\078\097\116\117\114\097\108"then local U=k[_CGear+2][math.floor(math.min(_Tune.Redline,math.max(_Tune.IdleRPM,_RPM))/100)]_BH=U.Horsepower+(U.HpSlope*((_RPM-math.floor(_RPM/100))/1000))%1 _BT=U.Torque+(U.TqSlope*((_RPM-math.floor(_RPM/100))/1000))%1 _HP=_NH+_BH*(_Boost/2)_OutTorque=_NT+_BT*(_Boost/2)else _HP=_NH _OutTorque=_NT end local Z=car.DriveSeat.CFrame.lookVector.y*N if _CGear==-1 then Z=-Z end _OutTorque=_OutTorque*math.max(1,1+Z)local a=0 local Y=0 local I=0 local B=0 for U,o in pairs(car.Wheels:GetChildren())do if o.Name=="\070\076"or o.Name=="\070\082"or o.Name=="\070"then a=a+o.RotVelocity.Magnitude Y=Y+1 elseif o.Name=="\082\076"or o.Name=="\082\082"or o.Name=="\082"then I=I+o.RotVelocity.Magnitude B=B+1 end end a=a/Y I=I/B local A=(a+I)/2 for U,o in pairs(car.Wheels:GetChildren())do local N=(CFrame.new(o.Position-(o.Arm.CFrame*R).lookVector,o.Position)*y).lookVector local q=1 local c=1 if o.Name=="\070\076"or o.Name=="\082\076"then q=-1 end if _Tune.Config=="\065\087\068"then _OutTorque=_OutTorque*G end if o.Name=="\070\076"or o.Name=="\070\082"then c=math.max(0,math.min(1,1+(((o.RotVelocity.Magnitude-a)/a)/(math.max(_Tune.FDiffSlipThres,1)/100))*((_Tune.FDiffLockThres-50)/50)))if _Tune.Config=="\065\087\068"then c=math.max(0,math.min(1,c*(1+(((a-A)/A)/(math.max(_Tune.CDiffSlipThres,1)/100))*((_Tune.CDiffLockThres-50)/50))))end elseif o.Name=="\082\076"or o.Name=="\082\082"then c=math.max(0,math.min(1,1+(((o.RotVelocity.Magnitude-I)/I)/(math.max(_Tune.RDiffSlipThres,1)/100))*((_Tune.RDiffLockThres-50)/50)))if _Tune.Config=="\065\087\068"then c=math.max(0,math.min(1,c*(1+(((I-A)/A)/(math.max(_Tune.CDiffSlipThres,1)/100))*((_Tune.CDiffLockThres-50)/50))))end end _TCSActive=false _ABSActive=false if _PBrake and(o.Name=="\082\082"or o.Name=="\082\076")then o["\035\065\086"].maxTorque=Vector3.new(math.abs(N.x),math.abs(N.y),math.abs(N.z))*PBrakeForce o["\035\065\086"].angularvelocity=Vector3.new()else if _GBrake==0 then local U=false for N,q in pairs(Drive)do if q==o then U=true end end if U then local U=1 if not script.Parent.IsOn.Value then U=0 end local R=1 if not _ClutchOn then R=0 end local y=_GThrot*_GThrotShift g=1 if _TCS then g=1-math.min(math.max(0,math.abs(o.RotVelocity.Magnitude*(o.Size.x/2)-o.Velocity.Magnitude)-_Tune.TCSThreshold)/_Tune.TCSGradient,1)*(1-_Tune.TCSLimit/100)end if g<1 then _TCSAmt=g _TCSActive=true end local G=1 if _CGear==-1 then G=-1 end o["\035\065\086"].maxTorque=((((((Vector3.new(math.abs(N.x),math.abs(N.y),math.abs(N.z))*_OutTorque)*(1+(o.RotVelocity.Magnitude/60)^1.15))*y)*g)*c)*U)*R o["\035\065\086"].angularvelocity=((N*q)*_spLimit)*G else o["\035\065\086"].maxTorque=Vector3.new()o["\035\065\086"].angularvelocity=Vector3.new()end else local U=_GBrake local q=1 if _ABS and math.abs(o.RotVelocity.Magnitude*(o.Size.x/2)-o.Velocity.Magnitude)-_Tune.ABSThreshold>0 then q=0 end _ABSActive=q<1 if o.Name=="\070\076"or o.Name=="\070\082"or o.Name=="\070"then o["\035\065\086"].maxTorque=((Vector3.new(math.abs(N.x),math.abs(N.y),math.abs(N.z))*FBrakeForce)*U)*q else o["\035\065\086"].maxTorque=((Vector3.new(math.abs(N.x),math.abs(N.y),math.abs(N.z))*RBrakeForce)*U)*q end o["\035\065\086"].angularvelocity=Vector3.new()end end end end


	local fFD = _Tune.FinalDrive*_Tune.FDMult
	local fFDr = fFD*30/math.pi
	local cGrav = workspace.Gravity*_Tune.InclineComp/32.2
	local wDRatio = wDia*math.pi/60
	local cfWRot = CFrame.Angles(math.pi/2,-math.pi/2,0)
	local cfYRot = CFrame.Angles(0,math.pi,0)
	local rtTwo = (2^.5)/2
	
	if _Tune.Aspiration == "Single" then
		_TCount = 1
		_TPsi = _Tune.Boost
	elseif _Tune.Aspiration == "Double" then
		_TCount = 2
		_TPsi = _Tune.Boost*2
	end

	--Horsepower Curve
	
	
	local HP=_Tune.Horsepower/100
	local HP_B=((_Tune.Horsepower*((_TPsi)*(_Tune.CompressRatio/10))/7.5)/2)/100
	local Peak=_Tune.PeakRPM/1000
	local Sharpness=_Tune.PeakSharpness
	local CurveMult=_Tune.CurveMult
	local EQ=_Tune.EqPoint/1000
	
	--Horsepower Curve
	
	function curveHP(RPM)
		RPM=RPM/1000
		return ((-(RPM-Peak)^2)*math.min(HP/(Peak^2),CurveMult^(Peak/HP))+HP)*(RPM-((RPM^Sharpness)/(Sharpness*Peak^(Sharpness-1))))
	end
	
	local PeakCurveHP = curveHP(_Tune.PeakRPM)
	
	function curvePSI(RPM)
		RPM=RPM/1000
		return ((-(RPM-Peak)^2)*math.min(HP_B/(Peak^2),CurveMult^(Peak/HP_B))+HP_B)*(RPM-((RPM^Sharpness)/(Sharpness*Peak^(Sharpness-1))))
	end
	local PeakCurvePSI = curvePSI(_Tune.PeakRPM)
	
	--Plot Current Horsepower
	function GetCurve(x,gear)
		local hp=(math.max(curveHP(x)/(PeakCurveHP/HP),0))*100
		return hp,((hp*(EQ/x))*_Tune.Ratios[gear+2]*fFD*hpScaling)*1000
	end
	
	--Plot Current Boost (addition to Horsepower)
	function GetPsiCurve(x,gear)
		local hp=(math.max(curvePSI(x)/(PeakCurvePSI/HP_B),0))*100
		return hp,((hp*(EQ/x))*_Tune.Ratios[gear+2]*fFD*hpScaling)*1000
	end	
	
	--Output Cache	
	local HPCache = {}
	local PSICache = {}
	
	for gear,ratio in pairs(_Tune.Ratios) do
		local nhpPlot = {}
		local bhpPlot = {}
		for rpm = math.floor(_Tune.IdleRPM/100),math.ceil((_Tune.Redline+100)/100) do
			local ntqPlot = {}
			local btqPlot = {}
			ntqPlot.Horsepower,ntqPlot.Torque = GetCurve(rpm*100,gear-2)
			btqPlot.Horsepower,btqPlot.Torque = GetPsiCurve(rpm*100,gear-2)
			hp1,tq1 = GetCurve((rpm+1)*100,gear-2)
			hp2,tq2 = GetPsiCurve((rpm+1)*100,gear-2)
			ntqPlot.HpSlope = (hp1 - ntqPlot.Horsepower)
			btqPlot.HpSlope = (hp2 - btqPlot.Horsepower)
			ntqPlot.TqSlope = (tq1 - ntqPlot.Torque)
			btqPlot.TqSlope = (tq2 - btqPlot.Torque)
			nhpPlot[rpm] = ntqPlot
			bhpPlot[rpm] = btqPlot
		end
		table.insert(HPCache,nhpPlot)
		table.insert(PSICache,bhpPlot)
	end

	--Powertrain
	wait()

	--Automatic Transmission
	function Auto()
		local maxSpin=0
		for i,v in pairs(Drive) do if v.RotVelocity.Magnitude>maxSpin then maxSpin = v.RotVelocity.Magnitude end end
		if _IsOn then
			_ClutchOn = true
			if _CGear >= 1 then
				if _GBrake > 0  and car.DriveSeat.Velocity.Magnitude < 5 then
					_CGear = 1
				else
					if _Tune.AutoShiftMode == "RPM" then
						if _RPM>(_Tune.PeakRPM+_Tune.AutoUpThresh) then
							if (_CGear ~= 0) and (_CGear ~= #_Tune.Ratios-2) then
								_GThrotShift = 0
								wait(_Tune.ShiftTime)
								_GThrotShift = 1
							end
							_CGear=math.min(_CGear+1,#_Tune.Ratios-2) 
						elseif math.max(math.min(maxSpin*_Tune.Ratios[_CGear+1]*fFDr,_Tune.Redline+100),_Tune.IdleRPM)<(_Tune.PeakRPM-_Tune.AutoDownThresh) then
							if _CGear ~= 1 then
								_GThrotShift = 0
								wait(_Tune.ShiftTime/2)
								_GThrotShift = 1
							end
							_CGear=math.max(_CGear-1,1)
						end
					else
						if car.DriveSeat.Velocity.Magnitude > math.ceil(wDRatio*(_Tune.PeakRPM+_Tune.AutoUpThresh)/_Tune.Ratios[_CGear+2]/fFD) then
							if (_CGear ~= 0) and (_CGear ~= #_Tune.Ratios-2) then
								_GThrotShift = 0
								wait(_Tune.ShiftTime)
								_GThrotShift = 1
							end
							_CGear=math.min(_CGear+1,#_Tune.Ratios-2)
						elseif car.DriveSeat.Velocity.Magnitude < math.ceil(wDRatio*(_Tune.PeakRPM-_Tune.AutoDownThresh)/_Tune.Ratios[_CGear+1]/fFD) then
							if _CGear ~= 1 then
								_GThrotShift = 0
								wait(_Tune.ShiftTime/2)
								_GThrotShift = 1
							end
							_CGear=math.max(_CGear-1,1)
						end
					end
				end
			end
		end 
	end
	
	local tqTCS = 1
	--Apply Power
	function Engine()
		--Neutral Gear
		if _CGear==0 then _ClutchOn = false end
	
		--Car Is Off
		local revMin = _Tune.IdleRPM
		if not _IsOn then 
			revMin = 0 
			_CGear = 0
			_ClutchOn = false
			_GThrot = _Tune.IdleThrottle/100
		end
		
		--Determine RPM
		local maxSpin=0
		local maxCount=0
		for i,v in pairs(Drive) do maxSpin = maxSpin + v.RotVelocity.Magnitude maxCount = maxCount + 1 end
		maxSpin=maxSpin/maxCount
		
		if _ClutchOn then
			if _Tune.DriveTransfer == "TorqueConverter" then
			local aRPM = math.max(math.min(maxSpin*_Tune.Ratios[_CGear+2]*fFDr,_Tune.Redline+100),revMin)+(((_Tune.TConverter+800)*_GThrot)-(_Tune.IdleRPM*_GThrot)-((38)*_Tune.IdleThrottle))
			local clutchP = math.min(math.abs((aRPM-((_Tune.TConverter-1000)*(_RPM/_Tune.Redline)*_GThrot))-_RPM)/_Tune.ClutchTol,.97)
			_RPM = _RPM*clutchP  +  (aRPM-((_Tune.TConverter-1000)*(_RPM/_Tune.Redline)*_GThrot))*(1-clutchP)
			end
			if _Tune.DriveTransfer == "Clutch" then
			local aRPM = math.max(math.min(maxSpin*_Tune.Ratios[_CGear+2]*fFDr,_Tune.Redline+100),revMin)
			local clutchP = math.min(math.abs(aRPM-_RPM)/_Tune.ClutchTol,.9)
			_RPM = _RPM*clutchP  +  aRPM*(1-clutchP)
			end
		else
			if _GThrot-(_Tune.IdleThrottle/100)>0 then
				if _RPM>_Tune.Redline then
					_RPM = _RPM-_Tune.RevBounce*2
				else
					_RPM = math.min(_RPM+(_Tune.RevAccel*((script.Parent.Values.RPM.Value/_Tune.Redline)))*_GThrot,_Tune.Redline+100)
				end
			else
				_RPM = math.max(_RPM-(_Tune.RevDecay*((script.Parent.Values.RPM.Value/_Tune.Redline))),revMin)
			end
		end
		
		--Rev Limiter
		_spLimit = (_Tune.Redline+100)/(fFDr*_Tune.Ratios[_CGear+2])
		if _RPM>_Tune.Redline then 
			if _CGear<#_Tune.Ratios-2 then
				_RPM = _RPM-_Tune.RevBounce
			else
				_RPM = _RPM-_Tune.RevBounce*.5
			end
		end
		
		local TPsi = _TPsi/_TCount
		_Boost = _Boost + ((((((_HP*(_GThrot*1.2)/_Tune.Horsepower)/8)-(((_Boost/TPsi*(TPsi/15)))))*((8/_Tune.TurboSize)*(1+(_Boost*2))))/TPsi)*15)
		if _Boost < 0.05 then _Boost = 0.05 elseif _Boost > 2 then _Boost = 2 end
		
		local cTq = HPCache[_CGear+2][math.floor(math.min(_Tune.Redline,math.max(_Tune.IdleRPM,_RPM))/100)]
		_NH = cTq.Horsepower+(cTq.HpSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
		_NT = cTq.Torque+(cTq.TqSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
		if _Tune.Aspiration ~= "Natural" then
			local bTq = PSICache[_CGear+2][math.floor(math.min(_Tune.Redline,math.max(_Tune.IdleRPM,_RPM))/100)]
			_BH = bTq.Horsepower+(bTq.HpSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
			_BT = bTq.Torque+(bTq.TqSlope*((_RPM-math.floor(_RPM/100))/1000)%1)
			_HP = _NH + (_BH*(_Boost/2))
			_OutTorque = _NT + (_BT*(_Boost/2))
		else
			_HP = _NH
			_OutTorque = _NT
		end
		
		local iComp =(car.DriveSeat.CFrame.lookVector.y)*cGrav
		if _CGear==-1 then iComp=-iComp end
		_OutTorque = _OutTorque*math.max(1,(1+iComp))
		
		--Average Rotational Speed Calculation
		local fwspeed=0
		local fwcount=0
		local rwspeed=0
		local rwcount=0
		
		for i,v in pairs(car.Wheels:GetChildren()) do
			if v.Name=="FL" or v.Name=="FR" or v.Name == "F" then
				fwspeed=fwspeed+v.RotVelocity.Magnitude
				fwcount=fwcount+1
			elseif v.Name=="RL" or v.Name=="RR" or v.Name == "R" then
				rwspeed=rwspeed+v.RotVelocity.Magnitude
				rwcount=rwcount+1
			end
		end
		fwspeed=fwspeed/fwcount
		rwspeed=rwspeed/rwcount	
		local cwspeed=(fwspeed+rwspeed)/2
		
		--Update Wheels
		for i,v in pairs(car.Wheels:GetChildren()) do
			--Reference Wheel Orientation
			local Ref=(CFrame.new(v.Position-((v.Arm.CFrame*cfWRot).lookVector),v.Position)*cfYRot).lookVector
			local aRef=1
			local diffMult=1
			if v.Name=="FL" or v.Name=="RL" then aRef=-1 end
			
			--AWD Torque Scaling
			if _Tune.Config == "AWD" then _OutTorque = _OutTorque*rtTwo end
			
			--Differential/Torque-Vectoring
			if v.Name=="FL" or v.Name=="FR" then
				diffMult=math.max(0,math.min(1,1+((((v.RotVelocity.Magnitude-fwspeed)/fwspeed)/(math.max(_Tune.FDiffSlipThres,1)/100))*((_Tune.FDiffLockThres-50)/50))))
				if _Tune.Config == "AWD" then
					diffMult=math.max(0,math.min(1,diffMult*(1+((((fwspeed-cwspeed)/cwspeed)/(math.max(_Tune.CDiffSlipThres,1)/100))*((_Tune.CDiffLockThres-50)/50)))))
				end
			elseif v.Name=="RL" or v.Name=="RR" then
				diffMult=math.max(0,math.min(1,1+((((v.RotVelocity.Magnitude-rwspeed)/rwspeed)/(math.max(_Tune.RDiffSlipThres,1)/100))*((_Tune.RDiffLockThres-50)/50))))
				if _Tune.Config == "AWD" then
					diffMult=math.max(0,math.min(1,diffMult*(1+((((rwspeed-cwspeed)/cwspeed)/(math.max(_Tune.CDiffSlipThres,1)/100))*((_Tune.CDiffLockThres-50)/50)))))
				end
			end
			
			_TCSActive = false
			_ABSActive = false
			--Output
			if _PBrake and (v.Name=="RR" or v.Name=="RL") then
				--PBrake
				v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*PBrakeForce
				v["#AV"].angularvelocity=Vector3.new()
			else
				--Apply Power
				if _GBrake==0 then
					local driven = false
					for _,a in pairs(Drive) do if a==v then driven = true end end
					if driven then
						local on=1
						if not script.Parent.IsOn.Value then on=0 end
						local clutch=1
						if not _ClutchOn then clutch=0 end
						local throt = _GThrot * _GThrotShift
						
						--Apply TCS
						tqTCS = 1
						if _TCS then
							tqTCS = 1-(math.min(math.max(0,math.abs(v.RotVelocity.Magnitude*(v.Size.x/2) - v.Velocity.Magnitude)-_Tune.TCSThreshold)/_Tune.TCSGradient,1)*(1-(_Tune.TCSLimit/100)))
						end
						if tqTCS < 1 then
							_TCSAmt = tqTCS
							_TCSActive = true
						end
						
						--Update Forces
						local dir=1
						if _CGear==-1 then dir = -1 end
						v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*_OutTorque*(1+(v.RotVelocity.Magnitude/60)^1.15)*throt*tqTCS*diffMult*on*clutch
						v["#AV"].angularvelocity=Ref*aRef*_spLimit*dir
					else
						v["#AV"].maxTorque=Vector3.new()
						v["#AV"].angularvelocity=Vector3.new()
					end
					
				--Brakes
				else
					local brake = _GBrake
					
					--Apply ABS
					local tqABS = 1
					if _ABS and math.abs(v.RotVelocity.Magnitude*(v.Size.x/2) - v.Velocity.Magnitude)-_Tune.ABSThreshold>0 then
						tqABS = 0
					end
					_ABSActive = (tqABS<1)
					
					--Update Forces
					if v.Name=="FL" or v.Name=="FR" or v.Name=="F" then
						v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*FBrakeForce*brake*tqABS
					else
						v["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*RBrakeForce*brake*tqABS
					end
					v["#AV"].angularvelocity=Vector3.new()
				end
			end
		end
	end
	
	
	