function Engine()script.Parent:WaitForChild("\071\097\117\103\101\115")script.Parent:WaitForChild("\083\116\097\116\117\115")local V local s local j={car.Wheels.FL:GetChildren(),car.Wheels.FR:GetChildren();car.Wheels.RL:GetChildren();car.Wheels.RR:GetChildren()}local l={Speed=0,ThrotAccel=.1;ThrotDecay=.4;ClutchAccel=.1;ClutchDecay=.5,FreeAccel=.1;FreeDecay=.01,BrakeAccel=.5,BrakeDecay=.5;ExpGradient=2,MaxTorque=100000;BrakeMaxTorque=100000;BExpGradient=2,Brakes=21000,ClutchGain=6000;ClutchStall=8000,ShiftSpeed=.01;ClutchShiftSpeed=.2,RevBounceP=.93,VariableThrotAdj=.1;Trans={{14000;18000,60,80,17;8,.7,.5;.7};{10000;16000,90,150;20;10,.2,.3;.8};{8000,13000,170,200,27,13,.1;.2;1};{5000,11000;220,240,28;20;.08;.15;1.2};{2500,8000,260;280;50,30,.06,.1,1.5},{2000,7000;300,330,100,50,.04;.1;2}};ReverseTq=14000,ReverseSp=30,FDiffPerc=-0.2,CDiffPerc=.25;RDiffPerc=-0.2,DTrainDist=-0.5;ThrotP=0;MaxThrotP=1,BrakeP=0,ClutchP=0;Throttle=0;Brake=0;Clutch=0;Gear=1;GearShift=1,PrevGear=1;RPM=0;Units={{"\083\080\083",1},{"\077\080\072";.682};{"\075\080\072",1.097}};CUnit=1}local b={TractionControl=true;FDownforce=0;RDownforce=40000,FFChange=0;FTolerance=10;FMaxDiff=40,FDecay=1,FGripGain=1,RFChange=-40000,RTolerance=10,RMaxDiff=40,RDecay=.01,RGripGain=.01;PBrakeForce=40000,SkidTol=40;PBrake=false;FSkid=0,RSkid=0}for V,s in pairs(j)do for V,s in pairs(s)do if s.Wheel:FindFirstChild("\035\065\086")then(s.Wheel:FindFirstChild("\035\065\086")):Destroy()end local j=Instance.new("\066\111\100\121\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121",s.Wheel)j.Name="\035\065\086"j.angularvelocity=Vector3.new(0,0,0)j.maxTorque=Vector3.new(0,0,0)j.P=l.MaxTorque end end mouse.Button1Up:connect(function()V=false end)mouse.Button1Down:connect(function()V=true end)mouse.Button2Up:connect(function()s=false end)mouse.Button2Down:connect(function()s=true end)mouse.WheelForward:connect(function()if GMode==1 then l.MaxThrotP=math.min(1,l.MaxThrotP+l.VariableThrotAdj)end end)mouse.WheelBackward:connect(function()if GMode==1 then l.MaxThrotP=math.max(0,l.MaxThrotP-l.VariableThrotAdj)end end)mouse.KeyDown:connect(function(V)if V=="\113"then l.PrevGear=l.Gear l.GearShift=0 l.Gear=math.max(l.Gear-1,-1)elseif V=="\101"then l.PrevGear=l.Gear l.GearShift=0 l.Gear=math.min(l.Gear+1,#l.Trans)elseif string.byte(V)==48 and GMode==1 or V=="\112"and GMode==0 then b.PBrake=1 elseif V=="\119"and GMode==1 or string.byte(V)==48 and GMode==0 then l.Clutch=1 elseif V=="\116"then b.TractionControl=not b.TractionControl end end)mouse.KeyUp:connect(function(V)if string.byte(V)==48 and GMode==1 or V=="\112"and GMode==0 then b.PBrake=0 elseif V=="\119"and GMode==1 or string.byte(V)==48 and GMode==0 then l.Clutch=0 end end)local function v()if GMode==0 then l.MaxThrotP=1 l.MaxBrakeP=1 l.Throttle=math.max(car.DriveSeat.Throttle,0)l.Brake=math.max(-car.DriveSeat.Throttle,0)elseif GMode==1 then l.MaxBrakeP=1 if V then l.Throttle=1 else l.Throttle=0 end if s then l.Brake=1 else l.Brake=0 end else b.PBrake=ButtonL1 l.Clutch=ButtonR1 l.Throttle=math.ceil(RTriggerValue)l.MaxThrotP=RTriggerValue l.Brake=math.ceil(LTriggerValue)l.MaxBrakeP=LTriggerValue^l.BExpGradient if l.ControllerGUp==0 and ButtonY==1 then l.PrevGear=l.Gear l.GearShift=0 l.Gear=math.min(l.Gear+1,#l.Trans)elseif l.ControllerGDown==0 and ButtonX==1 then l.PrevGear=l.Gear l.GearShift=0 l.Gear=math.max(l.Gear-1,-1)end l.ControllerGUp=ButtonY l.ControllerGDown=ButtonX end if l.Throttle==1 then l.ThrotP=math.min(l.MaxThrotP,l.ThrotP+l.ThrotAccel)else l.ThrotP=math.max(0,l.ThrotP-l.ThrotDecay)end if l.Brake==1 then l.BrakeP=math.min(l.MaxBrakeP,l.BrakeP+l.BrakeAccel)else l.BrakeP=math.max(0,l.BrakeP-l.BrakeDecay)end if l.Clutch==1 or l.Gear==0 then l.ClutchP=math.max(0,l.ClutchP-l.ClutchDecay)else l.ClutchP=math.min(1,l.ClutchP+l.ClutchAccel)end l.GearShift=math.min(1,(l.GearShift+l.ShiftSpeed)+l.ClutchShiftSpeed*(1-l.ClutchP))local v=l.Trans[math.max(l.Gear,1)][7]local Z=(l.Trans[math.max(l.Gear,1)][4]+l.Trans[math.max(l.Gear,1)][6])+3 local C=(l.Trans[math.max(l.PrevGear,1)][4]+l.Trans[math.max(l.PrevGear,1)][6])+3 local X=C+(Z-C)*l.GearShift local m=l.RPM*Z-l.RPM*C local w=1 local U=0 if math.abs(m)>v then w=l.GearShift if m>0 then U=l.Trans[l.Gear][8]*(1-l.GearShift)else U=l.Trans[l.Gear][9]*(1-l.GearShift)end end local e=0 local H=0 for V,s in pairs(j[1])do e=math.max(e,s.Wheel.RotVelocity.Magnitude)end for V,s in pairs(j[2])do e=math.max(e,s.Wheel.RotVelocity.Magnitude)end for V,s in pairs(j[3])do H=math.max(H,s.Wheel.RotVelocity.Magnitude)end for V,s in pairs(j[4])do H=math.max(H,s.Wheel.RotVelocity.Magnitude)end local p=H/X if l.DTrainDist==1 then p=e/X elseif l.DTrainDist~=-1 then p=math.max(p,e/X)end local K=l.ThrotP*2-1 if K>0 then K=K*l.FreeAccel else K=K*l.FreeDecay end l.RPM=math.min(1,math.max(0,p*l.ClutchP^.3,(l.RPM+K)*(1-l.ClutchP)^.3))for V,s in pairs(j)do for s,j in pairs(s)do local v=0 if l.Gear>0 then l.Speed=X if j.Wheel.RotVelocity.Magnitude<l.Trans[l.Gear][4]then local V=math.min(j.Wheel.RotVelocity.Magnitude/l.Trans[l.Gear][3],1)local s=l.Trans[l.Gear][2]-l.Trans[l.Gear][1]v=l.Trans[l.Gear][1]+V*s else if j.Wheel.RotVelocity.Magnitude<(l.Trans[l.Gear][4]+l.Trans[l.Gear][6])-1 then local V=(j.Wheel.RotVelocity.Magnitude-l.Trans[l.Gear][4])/l.Trans[l.Gear][5]local s=l.Trans[l.Gear][2]v=math.max(0,l.Trans[l.Gear][2]-V*s)else l.Speed=(l.Trans[l.Gear][4]+l.Trans[l.Gear][6])*l.RevBounceP v=l.Trans[l.Gear][2]*2 end end elseif l.Gear==0 then v=0 else l.Speed=-l.ReverseSp v=l.ReverseTq end if V==1 then v=((v*(1-GSteer*l.FDiffPerc))*(1+math.abs(GSteer*l.CDiffPerc)))*(1+l.DTrainDist)elseif V==2 then v=((v*(1+GSteer*l.FDiffPerc))*(1+math.abs(GSteer*l.CDiffPerc)))*(1+l.DTrainDist)elseif V==3 then v=((v*(1-GSteer*l.RDiffPerc))*(1-math.abs(GSteer*l.CDiffPerc)))*(1-l.DTrainDist)else v=((v*(1+GSteer*l.RDiffPerc))*(1-math.abs(GSteer*l.CDiffPerc)))*(1-l.DTrainDist)end v=(v*l.ThrotP)*l.ClutchP^l.ExpGradient v=v+v*U local Z=l.Brakes*l.BrakeP^l.ExpGradient v=math.abs(v-Z)l.Speed=l.Speed*(1-math.ceil(l.BrakeP))if V>2 and b.PBrake==1 then l.Speed=0 v=b.PBrakeForce end local C=j.Axle.CFrame.lookVector local m=l.Speed if V==1 or V==3 then m=-m end local e=1 if b.TractionControl then e=math.max(0,b.SkidTol-math.abs(j.Wheel.RotVelocity.Magnitude*(j.Wheel.Size.X/2)-j.Wheel.Velocity.Magnitude))/b.SkidTol if e<.7 then script.Parent.Gauges.Speedo.TC.Visible=true else script.Parent.Gauges.Speedo.TC.Visible=false end else script.Parent.Gauges.Speedo.TC.Visible=false end j.Wheel["\035\065\086"].maxTorque=(Vector3.new(math.abs(C.x),math.abs(C.y),math.abs(C.z))*v)*e j.Wheel["\035\065\086"].angularvelocity=(C*m)*w j.Wheel["\035\065\086"].P=l.MaxTorque*e end end end script.Parent.Gauges.Speedo.Units.MouseButton1Click:connect(function()if l.CUnit>=3 then l.CUnit=1 else l.CUnit=l.CUnit+1 end script.Parent.Gauges.Speedo.Units.Text=l.Units[l.CUnit][1]end)local Z={180354176,180354121,180354128,180354131;180354134,180354138,180354146,180354158,180354160;180354168,180355596,180354115}local function C()car.DriveSeat.Rev.Pitch=car.DriveSeat.Rev.SetPitch.Value+car.DriveSeat.Rev.SetRev.Value*l.RPM car.DriveSeat.Rel.Pitch=car.DriveSeat.Rel.SetPitch.Value+car.DriveSeat.Rel.SetRev.Value*l.RPM car.DriveSeat.Rev.Volume=car.DriveSeat.Rev.SetVolume.Value*l.ThrotP car.DriveSeat.Rel.Volume=car.DriveSeat.Rel.SetVolume.Value*(1-l.ThrotP)if l.Throttle~=1 then car.DriveSeat.Backfire.Volume=math.min(math.max((l.RPM-.5)/.5,0)*.7,car.DriveSeat.Backfire.Volume+.07)else car.DriveSeat.Backfire.Volume=math.max(car.DriveSeat.Backfire.Volume-.07,0)end if l.PrevThrot~=l.Throttle and l.RPM>.6 then local V=math.random(0,1)if V==1 then coroutine.resume(coroutine.create(function()for V,s in pairs(car.Body.Exhaust:GetChildren())do s.Afterburn.Rate=10 end wait(.1)for V,s in pairs(car.Body.Exhaust:GetChildren())do s.Afterburn.Rate=0 end end))end end local V=l.RPM*(l.Trans[math.max(l.Gear,1)][4]+l.Trans[math.max(l.Gear,1)][6])local s=math.min(1,math.max(0,V-l.Trans[math.max(l.Gear,1)][3]*.5)/(l.Trans[math.max(l.Gear,1)][3]-l.Trans[math.max(l.Gear,1)][3]*.5))local j=math.min(1,math.max(0,V-l.Trans[math.max(l.Gear,1)][4])/l.Trans[math.max(l.Gear,1)][6])local b=1-s local v=j*2 local C=0 if V>l.Trans[math.max(l.Gear,1)][4]then C=1-j else C=math.max(.45,s*2)end for V,s in pairs(script.Parent.Gauges.Tach:GetChildren())do local j=tonumber(string.match(s.Name,"\037\100\043"))if j~=nil then if j%2==0 then s.P.Size=UDim2.new(0,4,0,(1-math.abs(l.RPM-(j-1)/18))^12*-40-10)else s.P.Size=UDim2.new(0,6,0,(1-math.abs(l.RPM-(j-1)/18))^12*-40-10)end s.P.BackgroundColor3=Color3.new(v,C,b)end end local X=car.DriveSeat.Velocity.Magnitude*l.Units[l.CUnit][2]if X<1000 then local V=math.floor(X/100)local s=math.floor(X/10)-V*10 local j=(math.floor(X)-s*10)-V*100 script.Parent.Gauges.Speedo.A.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[j+1]if X>=10 then script.Parent.Gauges.Speedo.B.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[s+1]else script.Parent.Gauges.Speedo.B.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[12]end if X>=100 then script.Parent.Gauges.Speedo.C.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[V+1]else script.Parent.Gauges.Speedo.C.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[12]end else script.Parent.Gauges.Speedo.A.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[10]script.Parent.Gauges.Speedo.B.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[10]script.Parent.Gauges.Speedo.C.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[10]end if l.Gear>=0 then script.Parent.Gauges.Gear.G.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[l.Gear+1]else script.Parent.Gauges.Gear.G.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..Z[11]end script.Parent.Status.Clutch.B.Size=UDim2.new(0,4,-l.ClutchP,0)script.Parent.Status.Throttle.B.Size=UDim2.new(0,4,-l.ThrotP,0)script.Parent.Status.Brakes.B.Size=UDim2.new(0,4,-l.BrakeP,0)script.Parent.Status.ThrotLimit.B.Size=UDim2.new(0,4,-l.MaxThrotP,0)GSpeed=car.DriveSeat.Velocity.Magnitude GTopSp=l.Trans[#l.Trans][4]+l.Trans[#l.Trans][6]GRev=l.RPM GThrottle=l.ThrotP GBrake=l.BrakeP l.PrevThrot=l.Throttle end local function X()local V={}for V,s in pairs(j)do for V,s in pairs(s)do if s.Wheel:FindFirstChild("\083\109\111\107\101")~=nil and s.Wheel:FindFirstChild("\083\113\117\101\097\108")~=nil then if workspace:FindPartOnRay(Ray.new(s.Wheel.Position,Vector3.new(0,-s.Wheel.Size.X/2,0)),car)then s.Wheel.Smoke.Enabled=math.abs(s.Wheel.RotVelocity.Magnitude*(s.Wheel.Size.X/2)-s.Wheel.Velocity.Magnitude)>20 s.Wheel.Squeal.Volume=math.min(1,math.max(0,math.abs(s.Wheel.RotVelocity.Magnitude*(s.Wheel.Size.X/2)-s.Wheel.Velocity.Magnitude)-20)/20)else s.Wheel.Smoke.Enabled=false s.Wheel.Squeal.Volume=0 end end end end end table.insert(LoopRun,v)table.insert(LoopRun,C)table.insert(LoopRun,X)end Engine()

function Engine()
	script.Parent:WaitForChild("Gauges")
	script.Parent:WaitForChild("Status")
	local down1
	local down2
	local Drive={
		car.Wheels.FL:GetChildren(),
		car.Wheels.FR:GetChildren(),
		car.Wheels.RL:GetChildren(),
		car.Wheels.RR:GetChildren()
	}
	local Tc={
		Speed=0,
		ThrotAccel=.1,
		ThrotDecay=.4,
		ClutchAccel=.1,
		ClutchDecay=.5,
		FreeAccel=.1,
		FreeDecay=.01,
		BrakeAccel=.5,
		BrakeDecay=.5,
		ExpGradient=2,
		MaxTorque=100000,
		BrakeMaxTorque=100000,
		BExpGradient=2,
		Brakes=21000,		--Brake Force
		ClutchGain=6000,
		ClutchStall=8000,
		ShiftSpeed=.01,
		ClutchShiftSpeed=.2,
		RevBounceP=.93,
		VariableThrotAdj=.1,
		Trans={
	--	Tuning:  http://i.imgur.com/wbHZPI7.png
	--		   [1]		  [2]		  [3]		 [4]		   [5]		  [6]			[7]			  [8]		  [9]
	--	  	{Int Tq	, 	Peak Tq	, 	Peak Sp	, 	Max Sp	, 	Tq Decay, 	Limiter	,	C Tolerance	,	C Gain	,	C Stall	}
			{14000	,	18000	,	60		,	80		,	17		,	8		,	.7			,	.5		,	.7		},		--1st
			{10000	,	16000	,	90		,	150		,	20		,	10		,	.2			,	.3		,	.8		},		--2nd
			{8000	,	13000	,	170		,	200		,	27		,	13		,	.1			,	.2		,	1		},		--3rd
			{5000	,	11000	,	220		,	240		,	28		,	20		,	.08			,	.15		,	1.2		},		--4th
			{2500	,	8000	,	260		,	280		,	50		,	30		,	.06			,	.1		,	1.5		},		--5th
			{2000	,	7000	,	300		,	330		,	100		,	50		,	.04			,	.1		,	2		},		--6th
		},
		ReverseTq=14000,		--Reverse Torque
		ReverseSp=30,		--Max Reverse Speed
		FDiffPerc=-.2,		--Front Differential 	(-1 -> 1) *value < 0 is outer wheel biased
		CDiffPerc=.25,		--Center Differential	(-1 -> 1) *value < 0 is front biased
		RDiffPerc=-.2,		--Rear Differential		(-1 -> 1) *value < 0 is outer wheel biased
		DTrainDist=-.5,		--Power Distribution	(See below diagram)
					--  Rear  <-|-------|-------|-------|-------|->  Front
					-- Biased  -1        		0     		   	1   Biased
					--  	   RWD    		   AWD   		   FWD
	-------------------------------------------
		ThrotP=0,
		MaxThrotP=1,
		BrakeP=0,
		ClutchP=0,
		Throttle=0,
		Brake=0,
		Clutch=0,
		Gear=1,
		GearShift=1,
		PrevGear=1,
		RPM=0,
		Units={
			{"SPS",1},
			{"MPH",.682},
			{"KPH",1.097}
		},
		CUnit=1
	}
		local Friction={
		TractionControl=true,
		FDownforce=0000,	--Front Downforce (Unsprung)
		RDownforce=40000,	--Rear Downforce  (Unsprung)
		FFChange=0,
		FTolerance=10,
		FMaxDiff=40,
		FDecay=1,
		FGripGain=1,
		RFChange=-40000,
		RTolerance=10,
		RMaxDiff=40,
		RDecay=.01,
		RGripGain=.01,
		PBrakeForce=40000,
		SkidTol=40,
	-----------------------------------------
		PBrake=false,
		FSkid=0,
		RSkid=0,
	}
	for i,v in pairs(Drive) do
		for n,a in pairs(v) do
			if a.Wheel:FindFirstChild("#AV") then
				a.Wheel:FindFirstChild("#AV"):Destroy()
			end
			local AV=Instance.new("BodyAngularVelocity",a.Wheel)
			AV.Name="#AV"
			AV.angularvelocity=Vector3.new(0,0,0)
			AV.maxTorque=Vector3.new(0,0,0)
			AV.P=Tc.MaxTorque
		end
	end
	mouse.Button1Up:connect(function() down1=false end)
	mouse.Button1Down:connect(function() down1=true end)
	mouse.Button2Up:connect(function() down2=false end)
	mouse.Button2Down:connect(function() down2=true end)
	mouse.WheelForward:connect(function()
		if GMode==1 then
			Tc.MaxThrotP=math.min(1,Tc.MaxThrotP+Tc.VariableThrotAdj)
		end
	end)
	mouse.WheelBackward:connect(function()
		if GMode==1 then
			Tc.MaxThrotP=math.max(0,Tc.MaxThrotP-Tc.VariableThrotAdj)
		end
	end)
	mouse.KeyDown:connect(function(key)
		if key=="q" then
			Tc.PrevGear=Tc.Gear
			Tc.GearShift=0
			Tc.Gear=math.max(Tc.Gear-1,-1)
		elseif key=="e" then
			Tc.PrevGear=Tc.Gear
			Tc.GearShift=0
			Tc.Gear=math.min(Tc.Gear+1,#Tc.Trans)
		elseif (string.byte(key)==48 and GMode==1) or (key=="p" and GMode==0) then
			Friction.PBrake=1
		elseif (key=="w" and GMode==1) or (string.byte(key)==48 and GMode==0) then
			Tc.Clutch=1
		elseif key=="t" then
			Friction.TractionControl=not Friction.TractionControl
		end
	end)
	mouse.KeyUp:connect(function(key)
		if (string.byte(key)==48 and GMode==1) or (key=="p" and GMode==0) then
			Friction.PBrake=0
		elseif (key=="w" and GMode==1) or (string.byte(key)==48 and GMode==0) then
			Tc.Clutch=0
		end
	end)
	local function AChassis()
		if GMode==0 then
			Tc.MaxThrotP=1
			Tc.MaxBrakeP=1
			Tc.Throttle=math.max(car.DriveSeat.Throttle,0)
			Tc.Brake=math.max(-car.DriveSeat.Throttle,0)
		elseif GMode==1 then
			Tc.MaxBrakeP=1
			if down1 then
				Tc.Throttle=1
			else
				Tc.Throttle=0
			end
			if down2 then
				Tc.Brake=1
			else
				Tc.Brake=0
			end
		else
			Friction.PBrake=ButtonL1
			Tc.Clutch=ButtonR1
			Tc.Throttle=math.ceil(RTriggerValue)
			Tc.MaxThrotP=RTriggerValue
			Tc.Brake=math.ceil(LTriggerValue)
			Tc.MaxBrakeP=LTriggerValue^Tc.BExpGradient
			if Tc.ControllerGUp==0 and ButtonY==1 then
				Tc.PrevGear=Tc.Gear
				Tc.GearShift=0
				Tc.Gear=math.min(Tc.Gear+1,#Tc.Trans)
			elseif Tc.ControllerGDown==0 and ButtonX==1 then
				Tc.PrevGear=Tc.Gear
				Tc.GearShift=0
				Tc.Gear=math.max(Tc.Gear-1,-1)
			end
			Tc.ControllerGUp=ButtonY
			Tc.ControllerGDown=ButtonX
		end
		if Tc.Throttle==1 then
			Tc.ThrotP=math.min(Tc.MaxThrotP,Tc.ThrotP+Tc.ThrotAccel)
		else
			Tc.ThrotP=math.max(0,Tc.ThrotP-Tc.ThrotDecay)
		end
		if Tc.Brake==1 then
			Tc.BrakeP=math.min(Tc.MaxBrakeP,Tc.BrakeP+Tc.BrakeAccel)
		else
			Tc.BrakeP=math.max(0,Tc.BrakeP-Tc.BrakeDecay)
		end
		if Tc.Clutch==1 or Tc.Gear==0 then
			Tc.ClutchP=math.max(0,Tc.ClutchP-Tc.ClutchDecay)
		else
			Tc.ClutchP=math.min(1,Tc.ClutchP+Tc.ClutchAccel)
		end
		-------------
		Tc.GearShift=math.min(1,Tc.GearShift+Tc.ShiftSpeed+(Tc.ClutchShiftSpeed*(1-Tc.ClutchP)))
		---GearChangeBeta
		local tol=Tc.Trans[math.max(Tc.Gear,1)][7]
		local NSGear=Tc.Trans[math.max(Tc.Gear,1)][4]+Tc.Trans[math.max(Tc.Gear,1)][6]+3
		local OSGear=Tc.Trans[math.max(Tc.PrevGear,1)][4]+Tc.Trans[math.max(Tc.PrevGear,1)][6]+3
		local toprev=OSGear+((NSGear-OSGear)*Tc.GearShift)
		local gearDiff=(Tc.RPM*NSGear)-(Tc.RPM*OSGear)
		local stall=1
		local stalltq=0
		if math.abs(gearDiff)>tol then
			stall=Tc.GearShift
			if gearDiff>0 then
				stalltq=Tc.Trans[Tc.Gear][8]*(1-Tc.GearShift)
			else
				stalltq=Tc.Trans[Tc.Gear][9]*(1-Tc.GearShift)
			end
		end
		-------------
		local frev=0
		local rrev=0
		for i,v in pairs(Drive[1]) do
			frev=math.max(frev,v.Wheel.RotVelocity.Magnitude)
		end
		for i,v in pairs(Drive[2]) do
			frev=math.max(frev,v.Wheel.RotVelocity.Magnitude)
		end
		for i,v in pairs(Drive[3]) do
			rrev=math.max(rrev,v.Wheel.RotVelocity.Magnitude)
		end
		for i,v in pairs(Drive[4]) do
			rrev=math.max(rrev,v.Wheel.RotVelocity.Magnitude)
		end
		local rev=rrev/toprev
		if Tc.DTrainDist==1 then
			rev=frev/toprev
		elseif Tc.DTrainDist~=-1 then
			rev=math.max(rev,frev/toprev)
		end
		local rGain=(Tc.ThrotP*2)-1
		if rGain>0 then
			rGain=rGain*Tc.FreeAccel
		else
			rGain=rGain*Tc.FreeDecay
		end
		Tc.RPM=math.min(1,math.max(0,rev*Tc.ClutchP^.3,(Tc.RPM+rGain)*(1-Tc.ClutchP)^.3))
		-- A-Chassis 5.0
		for i,a in pairs(Drive) do
			for n,v in pairs(a) do
				local tq=0
				if Tc.Gear>0 then
					Tc.Speed=toprev
					if v.Wheel.RotVelocity.Magnitude<Tc.Trans[Tc.Gear][4] then
						local tPerc=math.min(v.Wheel.RotVelocity.Magnitude/Tc.Trans[Tc.Gear][3],1)
						local tqChange=Tc.Trans[Tc.Gear][2]-Tc.Trans[Tc.Gear][1]
						tq=(Tc.Trans[Tc.Gear][1]+(tPerc*tqChange))
					else
						if v.Wheel.RotVelocity.Magnitude<Tc.Trans[Tc.Gear][4]+Tc.Trans[Tc.Gear][6]-1 then
							local tPerc=(v.Wheel.RotVelocity.Magnitude-Tc.Trans[Tc.Gear][4])/Tc.Trans[Tc.Gear][5]
							local tqChange=Tc.Trans[Tc.Gear][2]
							tq=(math.max(0,Tc.Trans[Tc.Gear][2]-(tPerc*tqChange)))
						else
							Tc.Speed=(Tc.Trans[Tc.Gear][4]+Tc.Trans[Tc.Gear][6])*Tc.RevBounceP
							tq=Tc.Trans[Tc.Gear][2]*2
						end
					end
				elseif Tc.Gear==0 then
					tq=0
				else
					Tc.Speed=-Tc.ReverseSp
					tq=Tc.ReverseTq
				end
				if i==1 then
					tq=tq*(1-(GSteer*Tc.FDiffPerc))*(1+math.abs(GSteer*Tc.CDiffPerc))*(1+Tc.DTrainDist)
				elseif i==2 then
					tq=tq*(1+(GSteer*Tc.FDiffPerc))*(1+math.abs(GSteer*Tc.CDiffPerc))*(1+Tc.DTrainDist)
				elseif i==3 then
					tq=tq*(1-(GSteer*Tc.RDiffPerc))*(1-math.abs(GSteer*Tc.CDiffPerc))*(1-Tc.DTrainDist)
				else
					tq=tq*(1+(GSteer*Tc.RDiffPerc))*(1-math.abs(GSteer*Tc.CDiffPerc))*(1-Tc.DTrainDist)
				end
				tq=tq*Tc.ThrotP*Tc.ClutchP^Tc.ExpGradient
				tq=tq+(tq*stalltq)
				local br=Tc.Brakes*Tc.BrakeP^Tc.ExpGradient
				tq=math.abs(tq-br)
				Tc.Speed=Tc.Speed*(1-math.ceil(Tc.BrakeP))
				if i>2 and Friction.PBrake==1 then
					Tc.Speed=0
					tq=Friction.PBrakeForce
				end
				local Ref=v.Axle.CFrame.lookVector
				local Speed=Tc.Speed
				if i==1 or i==3 then Speed=-Speed end
				local TqVector=1
				if Friction.TractionControl then
					TqVector=math.max(0,Friction.SkidTol-math.abs((v.Wheel.RotVelocity.Magnitude*(v.Wheel.Size.X/2))-v.Wheel.Velocity.Magnitude))/Friction.SkidTol
					if TqVector<.7 then
						script.Parent.Gauges.Speedo.TC.Visible=true
					else
						script.Parent.Gauges.Speedo.TC.Visible=false
					end
				else
					script.Parent.Gauges.Speedo.TC.Visible=false
				end
				v.Wheel["#AV"].maxTorque=Vector3.new(math.abs(Ref.x),math.abs(Ref.y),math.abs(Ref.z))*tq*TqVector
				v.Wheel["#AV"].angularvelocity=Ref*Speed*stall
				v.Wheel["#AV"].P=Tc.MaxTorque*TqVector
			end
		end
	end
	script.Parent.Gauges.Speedo.Units.MouseButton1Click:connect(function()
		if Tc.CUnit>=3 then
			Tc.CUnit=1
		else
			Tc.CUnit=Tc.CUnit+1
		end
		script.Parent.Gauges.Speedo.Units.Text=Tc.Units[Tc.CUnit][1]
	end)
	local numbers={180354176,180354121,180354128,180354131,180354134,180354138,180354146,180354158,180354160,180354168,180355596,180354115}
	local function Speedometer()
		--Sound
		car.DriveSeat.Rev.Pitch=car.DriveSeat.Rev.SetPitch.Value+car.DriveSeat.Rev.SetRev.Value*Tc.RPM
		car.DriveSeat.Rel.Pitch=car.DriveSeat.Rel.SetPitch.Value+car.DriveSeat.Rel.SetRev.Value*Tc.RPM
		car.DriveSeat.Rev.Volume=car.DriveSeat.Rev.SetVolume.Value*Tc.ThrotP
		car.DriveSeat.Rel.Volume=car.DriveSeat.Rel.SetVolume.Value*(1-Tc.ThrotP)
		
		if Tc.Throttle ~= 1 then
			car.DriveSeat.Backfire.Volume=math.min(math.max((Tc.RPM-.5)/.5,0)*.7,car.DriveSeat.Backfire.Volume+.07)
		else
			car.DriveSeat.Backfire.Volume=math.max(car.DriveSeat.Backfire.Volume-.07,0)
		end
		--Afterburn
		if Tc.PrevThrot~=Tc.Throttle and Tc.RPM > .6 then
			local a=math.random(0,1)
			if a==1 then
				coroutine.resume(coroutine.create(function()
					for i,v in pairs(car.Body.Exhaust:GetChildren()) do
						v.Afterburn.Rate=10
					end
					wait(.1)
					for i,v in pairs(car.Body.Exhaust:GetChildren()) do
						v.Afterburn.Rate=0
					end
				end))
			end
		end
		--Speedo
		local fwheel=Tc.RPM*(Tc.Trans[math.max(Tc.Gear,1)][4]+Tc.Trans[math.max(Tc.Gear,1)][6])
		local z1=math.min(1,math.max(0,fwheel-(Tc.Trans[math.max(Tc.Gear,1)][3]*.5))/(Tc.Trans[math.max(Tc.Gear,1)][3]-(Tc.Trans[math.max(Tc.Gear,1)][3]*.5)))
		local z2=math.min(1,math.max(0,fwheel-Tc.Trans[math.max(Tc.Gear,1)][4])/Tc.Trans[math.max(Tc.Gear,1)][6])
		local blue=1-z1
		local red=z2*2
		local green=0
		if fwheel>Tc.Trans[math.max(Tc.Gear,1)][4] then
			green=1-z2
		else
			green=math.max(.45,z1*2)
		end
		for i,v in pairs(script.Parent.Gauges.Tach:GetChildren()) do
			local n=tonumber(string.match(v.Name, "%d+"))
			if n~=nil then
				if n%2 == 0 then
					v.P.Size=UDim2.new(0,4,0,((1-math.abs(Tc.RPM-((n-1)/18)))^12*-40)-10)
				else
					v.P.Size=UDim2.new(0,6,0,((1-math.abs(Tc.RPM-((n-1)/18)))^12*-40)-10)
				end
				v.P.BackgroundColor3 = Color3.new(red,green,blue)
			end
		end
		local sp=car.DriveSeat.Velocity.Magnitude*Tc.Units[Tc.CUnit][2]
		if sp<1000 then
			local nnn=math.floor(sp/100)
			local nn=(math.floor(sp/10))-(nnn*10)
			local n=(math.floor(sp)-(nn*10))-(nnn*100)
			script.Parent.Gauges.Speedo.A.Image="http://www.roblox.com/asset/?id="..numbers[n+1]
			if sp>=10 then
				script.Parent.Gauges.Speedo.B.Image="http://www.roblox.com/asset/?id="..numbers[nn+1]
			else
				script.Parent.Gauges.Speedo.B.Image="http://www.roblox.com/asset/?id="..numbers[12]
			end
			if sp>=100 then
				script.Parent.Gauges.Speedo.C.Image="http://www.roblox.com/asset/?id="..numbers[nnn+1]
			else
				script.Parent.Gauges.Speedo.C.Image="http://www.roblox.com/asset/?id="..numbers[12]
			end
		else
			script.Parent.Gauges.Speedo.A.Image="http://www.roblox.com/asset/?id="..numbers[10]
			script.Parent.Gauges.Speedo.B.Image="http://www.roblox.com/asset/?id="..numbers[10]	
			script.Parent.Gauges.Speedo.C.Image="http://www.roblox.com/asset/?id="..numbers[10]
		end
		if Tc.Gear>=0 then
			script.Parent.Gauges.Gear.G.Image="http://www.roblox.com/asset/?id="..numbers[Tc.Gear+1]
		else
			script.Parent.Gauges.Gear.G.Image="http://www.roblox.com/asset/?id="..numbers[11]
		end
		--Status Indicators
		script.Parent.Status.Clutch.B.Size=UDim2.new(0,4,-Tc.ClutchP,0)
		script.Parent.Status.Throttle.B.Size=UDim2.new(0,4,-Tc.ThrotP,0)
		script.Parent.Status.Brakes.B.Size=UDim2.new(0,4,-Tc.BrakeP,0)
		script.Parent.Status.ThrotLimit.B.Size=UDim2.new(0,4,-Tc.MaxThrotP,0)
		GSpeed=car.DriveSeat.Velocity.Magnitude
		GTopSp=Tc.Trans[#Tc.Trans][4]+Tc.Trans[#Tc.Trans][6]
		GRev=Tc.RPM
		GThrottle=Tc.ThrotP
		GBrake=Tc.BrakeP
		Tc.PrevThrot=Tc.Throttle
	end
	local function Smoke()
		local tireSP={}
		for i,v in pairs(Drive) do
			for n,a in pairs(v) do
				if a.Wheel:FindFirstChild("Smoke")~=nil and a.Wheel:FindFirstChild("Squeal")~=nil then
					if workspace:FindPartOnRay(Ray.new(a.Wheel.Position,Vector3.new(0,-a.Wheel.Size.X/2,0)),car) then
						a.Wheel.Smoke.Enabled=math.abs((a.Wheel.RotVelocity.Magnitude*(a.Wheel.Size.X/2))-a.Wheel.Velocity.Magnitude)>20
						a.Wheel.Squeal.Volume=math.min(1,math.max(0,math.abs((a.Wheel.RotVelocity.Magnitude*(a.Wheel.Size.X/2))-a.Wheel.Velocity.Magnitude)-20)/20)
					else
						a.Wheel.Smoke.Enabled=false
						a.Wheel.Squeal.Volume=0
					end
				end
			end
		end
	end
	--run:BindToRenderStep("AChassis",Enum.RenderPriority.Last.Value,AChassis)
	--run:BindToRenderStep("Speedometer",Enum.RenderPriority.Last.Value,Speedometer)
	--run:BindToRenderStep("Smoke",Enum.RenderPriority.Last.Value,Smoke)
	--table.insert(Binded,"AChassis")
	--table.insert(Binded,"Speedometer")
	--table.insert(Binded,"Smoke")
	table.insert(LoopRun,AChassis)
	table.insert(LoopRun,Speedometer)
	table.insert(LoopRun,Smoke)
end
Engine()