script.Parent:WaitForChild("\071\101\097\114")script.Parent:WaitForChild("\083\112\101\101\100")local n=script.Parent.Parent.Car.Value n.DriveSeat.HeadsUpDisplay=false local D=require(n["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local i=D.PeakRPM local E=D.Redline local L=math.ceil(E/1000)local W={}if D.Config=="\070\087\068"or D.Config=="\065\087\068"then if n.Wheels:FindFirstChild("\070\076")~=nil then table.insert(W,n.Wheels.FL)end if n.Wheels:FindFirstChild("\070\082")~=nil then table.insert(W,n.Wheels.FR)end if n.Wheels:FindFirstChild("\070")~=nil then table.insert(W,n.Wheels.F)end end if D.Config=="\082\087\068"or D.Config=="\065\087\068"then if n.Wheels:FindFirstChild("\082\076")~=nil then table.insert(W,n.Wheels.RL)end if n.Wheels:FindFirstChild("\082\082")~=nil then table.insert(W,n.Wheels.RR)end if n.Wheels:FindFirstChild("\082")~=nil then table.insert(W,n.Wheels.R)end end local X=0 for n,D in pairs(W)do if D.Size.x>X then X=D.Size.x end end W=nil local A=math.ceil(((((X*math.pi)*E)/60)/D.Ratios[#D.Ratios])/D.FinalDrive)local s=math.max(math.ceil(A/200)*20,20)if script.Parent.Parent.IsOn.Value then script.Parent:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end script.Parent.Parent.IsOn.Changed:connect(function()if script.Parent.Parent.IsOn.Value then script.Parent:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end end)script.Parent.Parent.Values.RPM.Changed:connect(function() end)script.Parent.Parent.Values.Gear.Changed:connect(function()local n=script.Parent.Parent.Values.Gear.Value if n==0 then n="\078"elseif n==-1 then n="\082"end script.Parent.Gear.Text=n end)script.Parent.Parent.Values.TCS.Changed:connect(function()if script.Parent.Parent.Values.TCS.Value then script.Parent.TCS.TextColor3=Color3.new(1,.66666666666667,0)script.Parent.TCS.TextStrokeColor3=Color3.new(1,.66666666666667,0)if script.Parent.Parent.Values.TCSActive.Value then wait()script.Parent.TCS.Visible=not script.Parent.TCS.Visible else wait()script.Parent.TCS.Visible=false end else script.Parent.TCS.Visible=true script.Parent.TCS.TextColor3=Color3.new(1,0,0)script.Parent.TCS.TextStrokeColor3=Color3.new(1,0,0)end end)script.Parent.Parent.Values.TCSActive.Changed:connect(function()if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=not script.Parent.TCS.Visible elseif not script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=true else wait()script.Parent.TCS.Visible=false end end)script.Parent.TCS.Changed:connect(function()if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=not script.Parent.TCS.Visible elseif not script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=true end end)script.Parent.Parent.Values.PBrake.Changed:connect(function()script.Parent.PBrake.Visible=script.Parent.Parent.Values.PBrake.Value end)script.Parent.Parent.Values.TransmissionMode.Changed:connect(function()if script.Parent.Parent.Values.TransmissionMode.Value=="\065\117\116\111"then script.Parent.TMode.Text="\065\047\084"script.Parent.TMode.BackgroundColor3=Color3.new(1,.66666666666667,0)elseif script.Parent.Parent.Values.TransmissionMode.Value=="\083\101\109\105"then script.Parent.TMode.Text="\083\047\084"script.Parent.TMode.BackgroundColor3=Color3.new(0,.66666666666667,.49803921568627)else script.Parent.TMode.Text="\077\047\084"script.Parent.TMode.BackgroundColor3=Color3.new(1,.33333333333333,.5)end end)script.Parent.Parent.Values.Velocity.Changed:connect(function(n)script.Parent.Speed.Text=math.floor(script.Parent.Parent.Values.Velocity.Value.Magnitude).." \083\080\083"end)
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						SecondLogic @ Inspare
]]

script.Parent:WaitForChild("Gear")
script.Parent:WaitForChild("Speed")

local car = script.Parent.Parent.Car.Value
car.DriveSeat.HeadsUpDisplay = false

local _Tune = require(car["A-Chassis Tune"])

local _pRPM = _Tune.PeakRPM
local _lRPM = _Tune.Redline

local revEnd = math.ceil(_lRPM / 1000)

local Drive = {}
if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
	if car.Wheels:FindFirstChild("FL") ~= nil then
		table.insert(Drive, car.Wheels.FL)
	end
	if car.Wheels:FindFirstChild("FR") ~= nil then
		table.insert(Drive, car.Wheels.FR)
	end
	if car.Wheels:FindFirstChild("F") ~= nil then
		table.insert(Drive, car.Wheels.F)
	end
end
if _Tune.Config == "RWD" or _Tune.Config == "AWD" then
	if car.Wheels:FindFirstChild("RL") ~= nil then
		table.insert(Drive, car.Wheels.RL)
	end
	if car.Wheels:FindFirstChild("RR") ~= nil then
		table.insert(Drive, car.Wheels.RR)
	end
	if car.Wheels:FindFirstChild("R") ~= nil then
		table.insert(Drive, car.Wheels.R)
	end
end

local wDia = 0
for i, v in pairs(Drive) do
	if v.Size.x > wDia then
		wDia = v.Size.x
	end
end
Drive = nil
local maxSpeed = math.ceil(wDia * math.pi * _lRPM / 60 / _Tune.Ratios[#_Tune.Ratios] / _Tune.FinalDrive)
local spInc = math.max(math.ceil(maxSpeed / 200) * 20, 20)

if script.Parent.Parent.IsOn.Value then
	script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true)
end

script.Parent.Parent.IsOn.Changed:connect(function()
	if script.Parent.Parent.IsOn.Value then
		script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true)
	end
end)

script.Parent.Parent.Values.RPM.Changed:connect(function() end)

script.Parent.Parent.Values.Gear.Changed:connect(function()
	local gearText = script.Parent.Parent.Values.Gear.Value
	if gearText == 0 then
		gearText = "N"
	elseif gearText == -1 then
		gearText = "R"
	end
	script.Parent.Gear.Text = gearText
end)

script.Parent.Parent.Values.TCS.Changed:connect(function()
	if script.Parent.Parent.Values.TCS.Value then
		script.Parent.TCS.TextColor3 = Color3.new(1, 170 / 255, 0)
		script.Parent.TCS.TextStrokeColor3 = Color3.new(1, 170 / 255, 0)
		if script.Parent.Parent.Values.TCSActive.Value then
			wait()
			script.Parent.TCS.Visible = not script.Parent.TCS.Visible
		else
			wait()
			script.Parent.TCS.Visible = false
		end
	else
		script.Parent.TCS.Visible = true
		script.Parent.TCS.TextColor3 = Color3.new(1, 0, 0)
		script.Parent.TCS.TextStrokeColor3 = Color3.new(1, 0, 0)
	end
end)

script.Parent.Parent.Values.TCSActive.Changed:connect(function()
	if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = not script.Parent.TCS.Visible
	elseif not script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = true
	else
		wait()
		script.Parent.TCS.Visible = false
	end
end)

script.Parent.TCS.Changed:connect(function()
	if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = not script.Parent.TCS.Visible
	elseif not script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = true
	end
end)

script.Parent.Parent.Values.PBrake.Changed:connect(function()
	script.Parent.PBrake.Visible = script.Parent.Parent.Values.PBrake.Value
end)

script.Parent.Parent.Values.TransmissionMode.Changed:connect(function()
	if script.Parent.Parent.Values.TransmissionMode.Value == "Auto" then
		script.Parent.TMode.Text = "A/T"
		script.Parent.TMode.BackgroundColor3 = Color3.new(1, 170 / 255, 0)
	elseif script.Parent.Parent.Values.TransmissionMode.Value == "Semi" then
		script.Parent.TMode.Text = "S/T"
		script.Parent.TMode.BackgroundColor3 = Color3.new(0, 170 / 255, 127 / 255)
	else
		script.Parent.TMode.Text = "M/T"
		script.Parent.TMode.BackgroundColor3 = Color3.new(1, 85 / 255, 0.5)
	end
end)

script.Parent.Parent.Values.Velocity.Changed:connect(function(property)
	script.Parent.Speed.Text = math.floor(script.Parent.Parent.Values.Velocity.Value.Magnitude) .. " SPS"
end)
