--(FL.RotVelocity.Magnitude+FR.RotVelocity.Magnitude+RL.RotVelocity.Magnitude+RR.RotVelocity.Magnitude+(speed/1.33034))/5


while wait() do
speed = carSeat.Velocity.Magnitude
power = 0
average = 10*(1-(carSeat.Storage.BrakeBias.Value/100))
track = carSeat.Velocity.Unit*carSeat.CFrame.lookVector
	slipDetection = track.X+track.Z
	
	Right = (carSeat.Parent.Parent.Wheels.RR.Wheel.Velocity.Magnitude+carSeat.Parent.Parent.Wheels.FR.Wheel.Velocity.Magnitude)/2
	Left = (carSeat.Parent.Parent.Wheels.RL.Wheel.Velocity.Magnitude+carSeat.Parent.Parent.Wheels.FL.Wheel.Velocity.Magnitude)/2
	
	if Right > Left then
	left = true
	else
		left = false
	end
	
if script.OVERRIDE.Value == false then
if carSeat.Storage.ASC.Value == true then
	if speed > 45 then
		if carSeat.Steer ~= 0 then
			if slipDetection < 0.995 and left == true then
						script.Toggle.Value = true
						carSeat.Storage.TC.Value = true
			else
				script.Toggle.Value = false
				carSeat.Storage.TC.Value = false
			end
		
		elseif carSeat.Steer == 0 then
			if slipDetection < 0.99984 and left == true then
			--carSeat.Storage.TC.Value = true
			--script.Toggle.Value = true
			
			else
				script.Toggle.Value = false
				carSeat.Storage.TC.Value = false
			end
		
		else 
			script.Toggle.Value = false
		end
		else script.Toggle.Value = false
	end
	--else script.Toggle.Value = false
end

	if speed > 0 then
		if script.Parent.Parent.Storage.Brake.Value ~= 0 or script.Toggle.Value == true then
				if FL.RotVelocity.Magnitude + power > average then
					script.Read.Value = true
					FLBRAKE.CanCollide = true
					FLBRAKEU.CanCollide = true --print("FL")

				elseif FL.RotVelocity.Magnitude + power < average then
					 script.Read.Value = false
					 FLBRAKE.CanCollide = false
					 FLBRAKEU.CanCollide = false	
			end
			
		elseif script.Parent.Parent.Storage.Brake.Value == 0 and script.Toggle.Value == false then
			script.Read.Value = false
			FLBRAKE.CanCollide = false
			FLBRAKEU.CanCollide = false
		end
	end
else
	FLBRAKE.CanCollide = true
	FLBRAKEU.CanCollide = true
					end
end

