--{HPattern, Automatic, DualClutch, CVT}

if script.Parent.Storage.EngineType.Value ~= "Electric" then
	if script.Parent.Storage.TransmissionType.Value == "HPattern" then
		if currentgear.Value == 3 and clutch.Value == true then
	--script.Parent.Storage.AutoClutch.Value = true
	else
	--script.Parent.Storage.AutoClutch.Value = false
	end
	elseif script.Parent.Storage.TransmissionType.Value == "Automatic" then
		
	elseif script.Parent.Storage.TransmissionType.Value == "DualClutch" then
		
	elseif script.Parent.Storage.TransmissionType.Value == "CVT" then
		vvv = 0.034
		vt = 0.7
		if rpm.Value >= 5000*convert and throttle.Value >= 1 then
			if gear1.Value > 0.7 and speed > 40 then
			gear1.Value = gear1.Value - 0.02*(2-(speed/130))
			elseif gear1.Value < 0.5  then
			gear1.Value = 0.5
			end
			
		elseif rpm.Value <= 4900*convert then
			if gear1.Value > 4 then
				gear1.Value = 4
			else
			gear1.Value = gear1.Value + 0.028*(2-(speed/130))
			end
	
		end
	
	end
end


if carSeat.Throttle == -1 then
drive = speed/1.298
else
	if carSeat.Dyno.Value == false then
if script.Parent.Storage.Drivetrain.Value == "RWD" then
	drive = 
	(carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude/8)+
	(carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude/8)
	orderch = ((carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude + carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude)/2)*1.298
	TC = rt
	torquesplit.Value = 100
	elseif script.Parent.Storage.Drivetrain.Value == "FWD" then
	drive = 
	(carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude/2)+
	(carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude/2)
	orderch = ((carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude + carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude)/2)*1.298
	torquesplit.Value = 0
	TC = ft
	elseif script.Parent.Storage.Drivetrain.Value == "AWD" then
	drive = 
	(carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude/2)+
	(carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude/2)
	orderch = ((carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude + carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude + carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude + carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude)/4)*1.298
	TC = (rt+ft)/2
end
	else
		if script.Parent.Storage.Drivetrain.Value == "RWD" then
	drive = 
	(carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude/2)+
	(carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude/2)
	
	elseif script.Parent.Storage.Drivetrain.Value == "FWD" then
	drive = 
	(carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude/2)+
	(carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude/2)
	
	elseif script.Parent.Storage.Drivetrain.Value == "AWD" then
	drive = 
	(carSeat.Parent.Parent.Wheels.FL.Wheel.RotVelocity.Magnitude/4)+
	(carSeat.Parent.Parent.Wheels.FR.Wheel.RotVelocity.Magnitude/4)+(carSeat.Parent.Parent.Wheels.RL.Wheel.RotVelocity.Magnitude/4)+
	(carSeat.Parent.Parent.Wheels.RR.Wheel.RotVelocity.Magnitude/4)
end
		end
end
xxx = (gear[currentgear.Value]/final.Value)*(111)
ovo = (gear[currentgear.Value]/final.Value)*1.5
trans.Value = drive

if currentgear.Value ~= 1 then
x1x = (gear[(currentgear.Value-1)]/final.Value)*(111)
xx1 = (gear[(currentgear.Value+1)]/final.Value)*(111)
else
x1x = 1
end

tran = clutch.Clutch.Value
wheelrpm = trans.Value*xxx
four = (gear[currentgear.Value]/final.Value)
if script.Parent.Functions.ShiftDownRequested.Value ~= true and script.Parent.Functions.ShiftUpRequested.Value ~= true then
rpm.Value = (engine.Value*(1-tran))+(tran*wheelrpm)
end

checkcluch = clutch.Clutch.Value

if clutch.Value == true then
	CT = 1
else
	CT = 0
end
