-- ~60 c/s

game["Run Service"].Heartbeat:connect(function(dt)	
	_IsOn = script.Parent.IsOn.Value
	_InControls = script.Parent.ControlsOpen.Value

	--Steering
	Steering(dt)

	--Gear
	Gear()

	--Power
	Engine(dt)

	--Update External Values
	script.Parent.Values.Gear.Value = _CGear
	script.Parent.Values.RPM.Value = _RPM
	script.Parent.Values.Boost.Value = ((_TBoost/2)*_TPsi)+((_SBoost/2)*_SPsi)
	script.Parent.Values.BoostTurbo.Value = (_TBoost/2)*_TPsi
	script.Parent.Values.BoostSuper.Value = (_SBoost/2)*_SPsi
	script.Parent.Values.HpNatural.Value = _NH
	script.Parent.Values.HpElectric.Value = _EH
	script.Parent.Values.HpTurbo.Value = _TH
	script.Parent.Values.HpSuper.Value = _SH
	script.Parent.Values.HpBoosted.Value = _BH
	script.Parent.Values.Horsepower.Value = _HP
	script.Parent.Values.TqNatural.Value = _NT/_Tune.Ratios[_CGear+1]/fFD/hpScaling
	script.Parent.Values.TqElectric.Value = _ET/_Tune.Ratios[_CGear+1]/fFD/hpScaling
	script.Parent.Values.TqTurbo.Value = _TT/_Tune.Ratios[_CGear+1]/fFD/hpScaling
	script.Parent.Values.TqSuper.Value = _ST/_Tune.Ratios[_CGear+1]/fFD/hpScaling
	script.Parent.Values.TqBoosted.Value = script.Parent.Values.TqTurbo.Value+script.Parent.Values.TqSuper.Value
	script.Parent.Values.Torque.Value = script.Parent.Values.TqNatural.Value+script.Parent.Values.TqElectric.Value+script.Parent.Values.TqBoosted.Value
	script.Parent.Values.TransmissionMode.Value = _TMode
	script.Parent.Values.Throttle.Value = _GThrot
	script.Parent.Values.Brake.Value = _GBrake
	if script.Parent.Values.AutoClutch.Value then
		script.Parent.Values.Clutch.Value = _Clutch
	end
	script.Parent.Values.SteerC.Value = _GSteerC
	script.Parent.Values.SteerT.Value = _GSteerT
	script.Parent.Values.PBrake.Value = _PBrake
	script.Parent.Values.TCS.Value = _TCS
	script.Parent.Values.TCSActive.Value = _TCSActive
	script.Parent.Values.TCSAmt.Value = 1-_TCSAmt
	script.Parent.Values.ABS.Value = _ABS
	script.Parent.Values.ABSActive.Value = _fABSActive or _rABSActive
	script.Parent.Values.MouseSteerOn.Value = _MSteer
	script.Parent.Values.Velocity.Value = bike.DriveSeat.Velocity
end)

while wait(.0667) do
	if _TMode == "Auto" then Auto() end
end