--(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*((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 carSeat.Steer ~= 0 then
		if slipDetection > 0.999 and left == true then
			script.Toggle.Value = true
		else
			script.Toggle.Value = false
		end
	else
		script.Toggle.Value = false
	end
end

if carSeat.Storage.Handbrake.Value == true then
	RLBRAKE.CanCollide = true
	RLBRAKEU.CanCollide = true
else
	if speed > 0 then
		if script.Parent.Parent.Storage.Brake.Value ~= 0 or script.Toggle.Value == true then
				if RL.RotVelocity.Magnitude + power > average then
					script.Read.Value = true
					RLBRAKE.CanCollide = true
					RLBRAKEU.CanCollide = true --print("RL")

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

