local Y=require(car["\065-\067\104\097\115\115\105\115 \084\117\110\101"].README)print("\047\047\073\078\083\080\065\082\069\058 \065\067\054 \076\111\097\100\101\100 - \066\117\105\108\100 "..Y)game["\082\117\110 \083\101\114\118\105\099\101"].Stepped:connect(function()Steering()RPM()Engine()_IsOn=script.Parent.IsOn.Value _InControls=script.Parent.ControlsOpen.Value script.Parent.Values.Gear.Value=_CGear script.Parent.Values.RPM.Value=_RPM script.Parent.Values.Horsepower.Value=_HP script.Parent.Values.Torque.Value=(_HP*_Tune.EqPoint)/_RPM script.Parent.Values.TransmissionMode.Value=_TMode script.Parent.Values.Throttle.Value=_GThrot script.Parent.Values.Brake.Value=_GBrake script.Parent.Values.SteerC.Value=_GSteerC*(1-math.min(car.DriveSeat.Velocity.Magnitude/_Tune.SteerDecay,1-_Tune.MinSteer/100))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.ABS.Value=_ABS script.Parent.Values.ABSActive.Value=_ABSActive script.Parent.Values.MouseSteerOn.Value=_MSteer script.Parent.Values.Velocity.Value=car.DriveSeat.Velocity end)local Q={{units="\077\080\072",scaling=.56818181818182;maxSpeed=230,spInc=20}}local J=nil local p=nil local H=0 local V=false local n=false local w=false local W=0 local F=false local U=false local C=75 local f=C local A=false local a=nil script.Parent.CruiseControl.Set.MouseButton1Down:Connect(function()if Q[1].scaling*car.DriveSeat.Velocity.Magnitude>2 then C=Q[1].scaling*car.DriveSeat.Velocity.Magnitude U=true script.Parent.CruiseControl.CruiseSpeed.TextColor3=Color3.fromRGB(255,85,0)script.Parent.CruiseControl.Return.ImageColor3=Color3.fromRGB(255,85,0)car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible=true car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible=true script.Parent.CruiseControl.CruiseSpeed.Text=math.floor(C)end end)script.Parent.CruiseControl.Res.MouseButton1Down:Connect(function()U=true script.Parent.CruiseControl.CruiseSpeed.Text=math.floor(C)script.Parent.CruiseControl.CruiseSpeed.TextColor3=Color3.fromRGB(255,85,0)script.Parent.CruiseControl.Return.ImageColor3=Color3.fromRGB(255,85,0)car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible=true car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible=true end)script.Parent.CruiseControl.Up.MouseButton1Down:Connect(function()C=C+1 script.Parent.CruiseControl.CruiseSpeed.Text=math.floor(C)end)script.Parent.CruiseControl.Return.MouseButton1Down:Connect(function()if U==true then U=false _GThrot=0 script.Parent.CruiseControl.CruiseSpeed.Text=math.floor(C)if A==true or ACCEasyBrake==true then A=false ACCEasyBrake=false _GBrake=0 end script.Parent.CruiseControl.CruiseSpeed.TextColor3=Color3.fromRGB(255,255,255)script.Parent.CruiseControl.Return.ImageColor3=Color3.fromRGB(255,255,255)car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible=false car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible=false else U=true script.Parent.CruiseControl.CruiseSpeed.Text=math.floor(C)script.Parent.CruiseControl.CruiseSpeed.TextColor3=Color3.fromRGB(255,85,0)script.Parent.CruiseControl.Return.ImageColor3=Color3.fromRGB(255,85,0)car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible=true car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible=true end end)script.Parent.CruiseControl.Down.MouseButton1Down:Connect(function()C=C-1 script.Parent.CruiseControl.CruiseSpeed.Text=math.floor(C)if C<=2 then U=false _GThrot=0 if A==true or ACCEasyBrake==true then A=false ACCEasyBrake=false _GBrake=0 end script.Parent.CruiseControl.CruiseSpeed.TextColor3=Color3.fromRGB(255,255,255)script.Parent.CruiseControl.Return.ImageColor3=Color3.fromRGB(255,255,255)car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible=false car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible=false end end)while wait(.0667)do if _Tune.AutoFlip then Flip()end if _GBrake>0 and(W==0 and(A==false and(ACCEasyBrake==false and(F==false and V==false))))then U=false _GThrot=0 if A==true then A=false _GBrake=0 end car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible=false car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible=false script.Parent.CruiseControl.CruiseSpeed.TextColor3=Color3.fromRGB(255,255,255)script.Parent.CruiseControl.Return.ImageColor3=Color3.fromRGB(255,255,255)end J=nil p=nil a=nil speed=Q[1].scaling*car.DriveSeat.Velocity.Magnitude for Y,Q in pairs(car.Body.Rays:GetChildren())do if speed>40 then ray=Ray.new(Q.Position,(Q.CFrame.lookVector*(speed*speed+speed))/50)elseif speed<=40 then ray=Ray.new(Q.Position,(Q.CFrame.lookVector*(speed*speed+speed))/50)end local p,H=workspace:FindPartOnRayWithIgnoreList(ray,{car.Body;car.Wheels,car.Misc})if p then if p.Anchored==false then J=p end end end if J and(speed>3 and((speed<60 or U==true)and(_GSteerT==0 and(_CGear>0 and(car.DriveSeat.Values.AEBisOn.Value==true and car.Electrics.Value==true)))))then _GBrake=1 car.SafetySystems:FireServer("\065\069\066",true)_GThrot=0 V=true if U==false then if W==0 then script.AssistantAlarm:Play()car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.BRAKE.Visible=true script.Parent.AC6_Stock_Gauges.EBrake.Visible=true end end W=1 if J.Velocity.Magnitude<=3 then F=true elseif U==true then TargetSpeed=Q[1].scaling*J.Velocity.Magnitude f=TargetSpeed end elseif V==true then V=false elseif V==false and W==1 then W=2 elseif V==false and(W==2 and F==false)then W=0 car.SafetySystems:FireServer("\065\069\066",false)script.Parent.AC6_Stock_Gauges.EBrake.Visible=false car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.BRAKE.Visible=false _GBrake=0 elseif F==true and speed<=.1 then F=false _GBrake=0 elseif U==true then if speed<f-5 and(A==false and W==0)then _GThrot=1 _GBrake=0 ACCEasyBrake=false elseif speed<f and(A==false and W==0)then _GThrot=.3 _GBrake=0 ACCEasyBrake=false elseif speed>f+5 and(A==false and W==0)then _GThrot=0 _GBrake=1 ACCEasyBrake=true elseif speed>f+3 and(A==false and W==0)then _GThrot=0 _GBrake=.4 ACCEasyBrake=true elseif speed>f+2 and(A==false and W==0)then _GThrot=0 _GBrake=.1 ACCEasyBrake=true elseif A==false and W==0 then _GThrot=.08 _GBrake=0 ACCEasyBrake=false end if W==0 then if A==false then for Y,Q in pairs(car.Body.Rays:GetChildren())do if speed>40 then ray=Ray.new(Q.Position,(Q.CFrame.lookVector*(speed*speed+speed))/25)elseif speed<=40 then ray=Ray.new(Q.Position,(Q.CFrame.lookVector*(speed*speed+speed))/10)end local J,H=workspace:FindPartOnRayWithIgnoreList(ray,{car.Body;car.Wheels,car.Misc})if J then if J.Anchored==false then p=J end end end else for Y,Q in pairs(car.Body.Rays:GetChildren())do ray=Ray.new(Q.Position,Q.CFrame.lookVector*20)local J,H=workspace:FindPartOnRayWithIgnoreList(ray,{car.Body;car.Wheels;car.Misc})if J then if J.Anchored==false then p=J end end end end if p==nil then f=C if ACCEasyBrake==false then _GBrake=0 end A=false elseif p.Velocity.Magnitude<3 then A=true _GThrot=0 _GBrake=1 f=Q[1].scaling*p.Velocity.Magnitude else A=false f=Q[1].scaling*p.Velocity.Magnitude end end end n=false w=false for Y,Q in pairs(car.Body.BSM:GetChildren())do ray=Ray.new(Q.Position,Q.CFrame.lookVector*25)local J,p=workspace:FindPartOnRayWithIgnoreList(ray,{car.Body;car.Wheels,car.Misc})if J then if J.Anchored==false then a=J if Q.Name:sub(1,1)=="\076"then n=true else w=true end end end end car.SafetySystems:FireServer("\066\083\077",n,w)end


	--Print Version
	local ver=require(car["A-Chassis Tune"].README)
	print("//INSPARE: AC6 Loaded - Build "..ver)
	
	--Runtime Loops
	
	-- ~60 c/s
	game["Run Service"].Stepped:connect(function()
		--Steering
		Steering()
		
		--RPM
		RPM()
		
		--Power
		Engine()
		
		--Update External Values
		_IsOn = script.Parent.IsOn.Value
		_InControls = script.Parent.ControlsOpen.Value
		script.Parent.Values.Gear.Value = _CGear
		script.Parent.Values.RPM.Value = _RPM
		script.Parent.Values.Horsepower.Value = _HP
		script.Parent.Values.Torque.Value = _HP * _Tune.EqPoint / _RPM
		script.Parent.Values.TransmissionMode.Value = _TMode
		script.Parent.Values.Throttle.Value = _GThrot
		script.Parent.Values.Brake.Value = _GBrake
		script.Parent.Values.SteerC.Value = _GSteerC*(1-math.min(car.DriveSeat.Velocity.Magnitude/_Tune.SteerDecay,1-(_Tune.MinSteer/100)))
		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.ABS.Value = _ABS
		script.Parent.Values.ABSActive.Value = _ABSActive
		script.Parent.Values.MouseSteerOn.Value = _MSteer
		script.Parent.Values.Velocity.Value = car.DriveSeat.Velocity
	end)
	--Bertox part
	local UNITS	= {{units = "MPH" ,scaling = (10/12) * (60/88) ,maxSpeed = 230,spInc = 20,}}
	local busyPart = nil
	local busyPart2 = nil
	local SpeedDistance = 0
	local AEBActive = false
	local BSMLeft = false
	local BSMRight = false
	local AEBBrake = 0
	local AEBFull = false
	local ACCEnabled = false
	local ACCOriginalSpeed = 75
	local ACCSpeed = ACCOriginalSpeed
	local ACCStop = false
	local bsmbusyPart = nil
	script.Parent.CruiseControl.Set.MouseButton1Down:Connect(function()
		if UNITS[1].scaling*car.DriveSeat.Velocity.Magnitude > 2 then
			ACCOriginalSpeed = UNITS[1].scaling*car.DriveSeat.Velocity.Magnitude
			ACCEnabled = true
			script.Parent.CruiseControl.CruiseSpeed.TextColor3 = Color3.fromRGB(255, 85, 0)
			script.Parent.CruiseControl.Return.ImageColor3 = Color3.fromRGB(255, 85, 0)
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible = true
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible = true
			script.Parent.CruiseControl.CruiseSpeed.Text = math.floor(ACCOriginalSpeed)
		end
	end)
	script.Parent.CruiseControl.Res.MouseButton1Down:Connect(function()
		ACCEnabled = true
		script.Parent.CruiseControl.CruiseSpeed.Text = math.floor(ACCOriginalSpeed)
		script.Parent.CruiseControl.CruiseSpeed.TextColor3 = Color3.fromRGB(255, 85, 0)
		script.Parent.CruiseControl.Return.ImageColor3 = Color3.fromRGB(255, 85, 0)
		car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible = true
		car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible = true
	end)
	script.Parent.CruiseControl.Up.MouseButton1Down:Connect(function()
		ACCOriginalSpeed = ACCOriginalSpeed + 1
		script.Parent.CruiseControl.CruiseSpeed.Text = math.floor(ACCOriginalSpeed)
	end)
	script.Parent.CruiseControl.Return.MouseButton1Down:Connect(function()
		if ACCEnabled == true then
			ACCEnabled = false
			_GThrot = 0
			script.Parent.CruiseControl.CruiseSpeed.Text = math.floor(ACCOriginalSpeed)
			if (ACCStop == true or ACCEasyBrake == true) then
				ACCStop = false
				ACCEasyBrake = false
				_GBrake = 0
			end
			script.Parent.CruiseControl.CruiseSpeed.TextColor3 = Color3.fromRGB(255,255,255)
			script.Parent.CruiseControl.Return.ImageColor3 = Color3.fromRGB(255,255,255)
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible = false
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible = false
			
		else
			ACCEnabled = true
			script.Parent.CruiseControl.CruiseSpeed.Text = math.floor(ACCOriginalSpeed)
			script.Parent.CruiseControl.CruiseSpeed.TextColor3 = Color3.fromRGB(255, 85, 0)
			script.Parent.CruiseControl.Return.ImageColor3 = Color3.fromRGB(255, 85, 0)
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible = true
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible = true
		end
	end)
	script.Parent.CruiseControl.Down.MouseButton1Down:Connect(function()
		ACCOriginalSpeed = ACCOriginalSpeed - 1
		script.Parent.CruiseControl.CruiseSpeed.Text = math.floor(ACCOriginalSpeed)
		if ACCOriginalSpeed <= 2 then
			ACCEnabled = false
			_GThrot = 0
			if (ACCStop == true or ACCEasyBrake == true) then
				ACCStop = false
				ACCEasyBrake = false
				_GBrake = 0
			end
			script.Parent.CruiseControl.CruiseSpeed.TextColor3 = Color3.fromRGB(255,255,255)
			script.Parent.CruiseControl.Return.ImageColor3 = Color3.fromRGB(255,255,255)
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible = false
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible = false
		end
	end)
	--Bertox part end
	-- ~15 c/s
	
	while wait(.0667) do
		--Flip
		if _Tune.AutoFlip then Flip() end
		
		--[[Bertox'Scripts begins here]]
		
	    --AEB
		if _GBrake > 0 and AEBBrake == 0 and ACCStop == false and ACCEasyBrake == false and AEBFull == false and AEBActive == false then
			ACCEnabled = false
			_GThrot = 0
			if ACCStop == true then
				ACCStop = false
				_GBrake = 0
			end
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl.Visible = false
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.CruiseControl2.Visible = false
			script.Parent.CruiseControl.CruiseSpeed.TextColor3 = Color3.fromRGB(255,255,255)
			script.Parent.CruiseControl.Return.ImageColor3 = Color3.fromRGB(255,255,255)
		end
		busyPart = nil
		busyPart2 = nil
		bsmbusyPart = nil
		speed = UNITS[1].scaling*car.DriveSeat.Velocity.Magnitude
		for i,v in pairs(car.Body.Rays:GetChildren()) do
			if speed > 40 then
				ray = Ray.new(v.Position, v.CFrame.lookVector*(speed*speed+speed)/50)
			elseif speed <= 40 then
				ray = Ray.new(v.Position, v.CFrame.lookVector*(speed*speed+speed )/50)
			end
			local part, endPoint = workspace:FindPartOnRayWithIgnoreList(ray,{car.Body,car.Wheels,car.Misc})
			if part then
				if part.Anchored == false then
					busyPart = part
				end
			end
		end
		if busyPart and speed > 3 and (speed < 60 or ACCEnabled == true) and _GSteerT == 0 and _CGear > 0 and car.DriveSeat.Values.AEBisOn.Value == true and car.Electrics.Value == true then
			--print("BLOCKING PART: " ,busyPart.Name, " DISTANCE: " , math.floor((busyPart.Position - car.DriveSeat.Position).Magnitude), " CAR SPEED: ", math.floor(speed), "  -  ", math.floor((busyPart.Position - car.DriveSeat.Position).Magnitude-speed))
			_GBrake = 1
			car.SafetySystems:FireServer("AEB",true)
			_GThrot = 0
			AEBActive = true
			if ACCEnabled == false then
				if AEBBrake == 0 then
					script.AssistantAlarm:Play()
					car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.BRAKE.Visible = true
					script.Parent.AC6_Stock_Gauges.EBrake.Visible = true
				end
			end
			AEBBrake = 1
			if busyPart.Velocity.Magnitude <= 3 then
				AEBFull = true
			elseif ACCEnabled == true then
				TargetSpeed = UNITS[1].scaling*busyPart.Velocity.Magnitude
				ACCSpeed = TargetSpeed
			end
		elseif AEBActive == true then
			AEBActive = false
		elseif AEBActive == false and AEBBrake == 1 then
			AEBBrake = 2
		elseif AEBActive == false and AEBBrake == 2 and AEBFull == false then
			AEBBrake = 0
			car.SafetySystems:FireServer("AEB",false)
			script.Parent.AC6_Stock_Gauges.EBrake.Visible = false
			car.Body.Display.GaugeDisplay.BMWGauges.BMWSystem.SymbolLights.BRAKE.Visible = false
			_GBrake = 0
		elseif AEBFull == true and speed <= 0.1 then
			AEBFull = false
			_GBrake = 0
		elseif ACCEnabled == true then
			if speed < ACCSpeed-5 and ACCStop == false and AEBBrake == 0 then
				_GThrot = 1
				_GBrake = 0
				ACCEasyBrake = false
			elseif speed < ACCSpeed and ACCStop == false and AEBBrake == 0 then
				_GThrot = 0.3
				_GBrake = 0
				ACCEasyBrake = false
			elseif speed > ACCSpeed+5 and ACCStop == false and AEBBrake == 0 then
				_GThrot = 0
				_GBrake = 1
				ACCEasyBrake = true
			elseif speed > ACCSpeed+3 and ACCStop == false and AEBBrake == 0 then
				_GThrot = 0
				_GBrake = 0.4
				ACCEasyBrake = true
			elseif speed > ACCSpeed+2 and ACCStop == false and AEBBrake == 0 then
				_GThrot = 0
				_GBrake = 0.1
				ACCEasyBrake = true
			elseif ACCStop == false and AEBBrake == 0 then
				_GThrot = 0.08
				_GBrake = 0
				ACCEasyBrake = false
			end
			if AEBBrake == 0 then
				if ACCStop == false then
					for i,v in pairs(car.Body.Rays:GetChildren()) do
						if speed > 40 then
							ray = Ray.new(v.Position, v.CFrame.lookVector*(speed*speed+speed)/25)
						elseif speed <= 40 then
							ray = Ray.new(v.Position, v.CFrame.lookVector*(speed*speed+speed )/10)
						end
						local part, endPoint = workspace:FindPartOnRayWithIgnoreList(ray,{car.Body,car.Wheels,car.Misc})
						if part then
							if part.Anchored == false then
								busyPart2 = part
							end
						end
					end
				else
					for i,v in pairs(car.Body.Rays:GetChildren()) do
						ray = Ray.new(v.Position, v.CFrame.lookVector*20)
						local part, endPoint = workspace:FindPartOnRayWithIgnoreList(ray,{car.Body,car.Wheels,car.Misc})
						if part then
							if part.Anchored == false then
								busyPart2 = part
							end
						end
					end
				end
				if busyPart2 == nil then
					ACCSpeed = ACCOriginalSpeed
					if ACCEasyBrake == false then
						_GBrake = 0
					end
					ACCStop = false
				elseif busyPart2.Velocity.Magnitude < 3 then
					ACCStop = true
					_GThrot = 0
					_GBrake = 1
					ACCSpeed = UNITS[1].scaling*busyPart2.Velocity.Magnitude
				else
					ACCStop = false
					ACCSpeed = UNITS[1].scaling*busyPart2.Velocity.Magnitude
				end
			end
				end
		BSMLeft = false
		BSMRight = false
		for i,v in pairs(car.Body.BSM:GetChildren()) do
			ray = Ray.new(v.Position, v.CFrame.lookVector*25)
			local part, endPoint = workspace:FindPartOnRayWithIgnoreList(ray,{car.Body,car.Wheels,car.Misc})
			if part then
				if part.Anchored == false then
					bsmbusyPart = part
					if v.Name:sub(1,1) == "L" then
						BSMLeft = true
					else
						BSMRight = true
					end
				end
			end
		end
		car.SafetySystems:FireServer("BSM",BSMLeft,BSMRight)
		--[[Bertox'Scripts ends here]]
	end